public string Post([FromBody] HugModel model) { //_logger.Log("Post Started"); var hugs = _dbService.GetHugs(); int exist = hugs.Where(x => x.Id == model.Id).Count(); if (exist == 0) { Hug newHug = new Hug(); newHug.Id = model.Id; newHug.To = model.To; newHug.From = model.From; newHug.Reason = model.Reason; newHug.Created = model.Created; _dbService.AddHug(newHug); return("Hug added"); } else { return("Hug exists already"); } }
public string Patch([FromBody] HugModel model) { //_logger.Log("Patch Started"); var hugs = _dbService.GetHugs(); int isthere = hugs.Where(x => x.Id == model.Id).Count(); if (isthere == 1) { Hug exists = hugs.Find(x => x.Id == model.Id); if (!CheckNullOrEmpty(model.Reason)) { exists.Reason = model.Reason; } if (!CheckNullOrEmpty(model.To)) { exists.To = model.To; } if (!CheckNullOrEmpty(model.From)) { exists.From = model.From; } if (!CheckNullOrEmpty(model.Created)) { exists.Created = model.Created; } return("Hug updated"); } else { return("Hug does not exist that you want to update"); } }
public void Put([FromBody] HugModel model) { var newHug = new Hug { From = model.From, To = model.To, Reason = model.Reason, Created = model.Created, Id = model.Id }; _dbManeger.PutHug(newHug); }
public void Post([FromBody] HugModel model) { _logger.Log("Post started"); var mappedHug = new Hug { Id = model.Id, From = model.From, To = model.To, Reason = model.Reason, Created = model.Created }; _dbManager.InsertHug(mappedHug); }
public string Put([FromBody] HugModel model) { //_logger.Log("Put Started"); var hugs = _dbService.GetHugs(); int isthere = hugs.Where(x => x.Id == model.Id).Count(); if (isthere == 1) { Hug exists = hugs.Find(x => x.Id == model.Id); exists.Reason = model.Reason; exists.To = model.To; exists.From = model.From; exists.Created = model.Created; return("Hug updated"); } else { return("Hug does not exist that you want to update"); } }