From 631c205f1a9962c97dd0fc37b76d33b42f2d0761 Mon Sep 17 00:00:00 2001 From: "chris.watts90@outlook.com" Date: Thu, 16 Mar 2017 23:06:49 +0000 Subject: [PATCH] add no caching attribute for group data. change UpdateGroup method so that it can create a group as well as update it. #30 --- .../Controllers/GroupController.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/GroupController.cs b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/GroupController.cs index adf1af4..a548472 100644 --- a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/GroupController.cs +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/GroupController.cs @@ -1,5 +1,6 @@ using System; using System.Web.Http; +using WindowsDataCenter.Helpers; using Interfaces; namespace WindowsDataCenter @@ -16,6 +17,7 @@ namespace WindowsDataCenter [HttpGet] [Route("")] + [CacheControl(MaxAge = 0)] public IHttpActionResult GetGroups() { var groupList = new GroupList {Groups = _repo.GetGroups()}; @@ -24,6 +26,7 @@ namespace WindowsDataCenter [HttpPost] [Route("create")] + [CacheControl(MaxAge = 0)] public IHttpActionResult CreateGroup([FromBody] Group group) { int groupId; @@ -34,6 +37,7 @@ namespace WindowsDataCenter [HttpDelete] [Route("delete")] + [CacheControl(MaxAge = 0)] public IHttpActionResult DeleteGroup([FromUri]int groupId) { //_repo.DeleteGroup(groupId); @@ -42,10 +46,20 @@ namespace WindowsDataCenter [HttpPost] [Route("edit")] + [CacheControl(MaxAge = 0)] public IHttpActionResult UpdateGroup([FromBody] Group group) { - //_repo.UpdateGroup(group); - throw new NotImplementedException(); + if (group.Id == -1) + { + int groupId; + _repo.CreateGroup(group, out groupId); + group.Id = groupId; + } + else + { + _repo.UpdateGroup(group); + } + return Ok(group.Id); } } }