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:
parent
33f1769d66
commit
631c205f1a
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Web.Http;
|
using System.Web.Http;
|
||||||
|
using WindowsDataCenter.Helpers;
|
||||||
using Interfaces;
|
using Interfaces;
|
||||||
|
|
||||||
namespace WindowsDataCenter
|
namespace WindowsDataCenter
|
||||||
@ -16,6 +17,7 @@ namespace WindowsDataCenter
|
|||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("")]
|
[Route("")]
|
||||||
|
[CacheControl(MaxAge = 0)]
|
||||||
public IHttpActionResult GetGroups()
|
public IHttpActionResult GetGroups()
|
||||||
{
|
{
|
||||||
var groupList = new GroupList {Groups = _repo.GetGroups()};
|
var groupList = new GroupList {Groups = _repo.GetGroups()};
|
||||||
@ -24,6 +26,7 @@ namespace WindowsDataCenter
|
|||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("create")]
|
[Route("create")]
|
||||||
|
[CacheControl(MaxAge = 0)]
|
||||||
public IHttpActionResult CreateGroup([FromBody] Group group)
|
public IHttpActionResult CreateGroup([FromBody] Group group)
|
||||||
{
|
{
|
||||||
int groupId;
|
int groupId;
|
||||||
@ -34,6 +37,7 @@ namespace WindowsDataCenter
|
|||||||
|
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
[Route("delete")]
|
[Route("delete")]
|
||||||
|
[CacheControl(MaxAge = 0)]
|
||||||
public IHttpActionResult DeleteGroup([FromUri]int groupId)
|
public IHttpActionResult DeleteGroup([FromUri]int groupId)
|
||||||
{
|
{
|
||||||
//_repo.DeleteGroup(groupId);
|
//_repo.DeleteGroup(groupId);
|
||||||
@ -42,10 +46,20 @@ namespace WindowsDataCenter
|
|||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("edit")]
|
[Route("edit")]
|
||||||
|
[CacheControl(MaxAge = 0)]
|
||||||
public IHttpActionResult UpdateGroup([FromBody] Group group)
|
public IHttpActionResult UpdateGroup([FromBody] Group group)
|
||||||
{
|
{
|
||||||
//_repo.UpdateGroup(group);
|
if (group.Id == -1)
|
||||||
throw new NotImplementedException();
|
{
|
||||||
|
int groupId;
|
||||||
|
_repo.CreateGroup(group, out groupId);
|
||||||
|
group.Id = groupId;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_repo.UpdateGroup(group);
|
||||||
|
}
|
||||||
|
return Ok(group.Id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user