added cache control attributes.

tidied code. removed commenting for now. need to add this in shortly.
#29
This commit is contained in:
Watts 2017-04-13 20:59:40 +01:00
parent 64018ef8db
commit f1371f1f99

View File

@ -1,13 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
using System.Web.Http.Controllers;
using WindowsDataCenter.Helpers;
using Interfaces;
namespace WindowsDataCenter.Controllers
namespace WindowsDataCenter
{
[RoutePrefix("api/logs")]
public class LogsController:ApiController
@ -28,30 +24,20 @@ namespace WindowsDataCenter.Controllers
_repo = repo;
_logger = logger;
}
/// <summary>
///
/// </summary>
/// <param name="log"></param>
/// <returns></returns>
[HttpPost]
[Route("create")]
[CacheControl(MaxAge = 0)]
public IHttpActionResult CreateAndEditResultLog([FromBody] TimeLog log)
{
log.Source = LogSource.UI;
if (log.Id > 0)
{
_repo.UpdateLog(log);
}
else
{
_repo.CreateLog(log);
}
return Ok();
var resp = log.Id > 0 ? _repo.UpdateLog(log) : _repo.CreateLog(log);
return Ok(new {Id=log.Id, OperationResponse=resp});
}
[HttpDelete]
[Route("delete")]
[CacheControl(MaxAge = 0)]
public IHttpActionResult DeleteLog([FromBody] TimeLog log)
{
_logger.Info("Removing Log {0} for user id {1}", log.Id, log.UserId);