add no caching attribute for group data.

change UpdateGroup method so that it can create a group as well as update it.
#30
This commit is contained in:
chris.watts90@outlook.com 2017-03-16 23:06:49 +00:00
parent 33f1769d66
commit 631c205f1a

View File

@ -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);
}
}
}