public static Disagreement AddDisagreement(Disagreement action) { using (var repo = new CRUDRepository <Disagreement>()) { if (action.Id > 0) { var previous = repo.GetQuery <Disagreement>(c => c.Id == action.Id) .Include(c => c.CreatedBy) .FirstOrDefault(); previous.ConcurrentDate = action.ConcurrentDate; previous.ConcurrentDescription = action.ConcurrentDescription; previous.ConcurrentPieces = action.ConcurrentPieces; previous.DisagreementOnDate = action.DisagreementOnDate; previous.DisagreementOnDescription = action.DisagreementOnDescription; previous.DisagreementOnPiece = action.DisagreementOnPiece; previous.Comment = action.Comment; repo.Update(previous); return(previous); } else { action = repo.Add(action); action.CreatedBy = BLLUsers.GetUserById(action.IdUser); return(action); } } }
public ContentResult AddAction(Disagreement disagreement) { disagreement.IdUser = User.Identity.GetId(); return(new ContentResult() { Content = JsonHelper.GetJsonString(BLLDisagreements.AddDisagreement(disagreement)), ContentType = "application/json" }); // return new JsonResult() { Data = BLLDisagreements.AddDisagreement(disagreement), JsonRequestBehavior = JsonRequestBehavior.AllowGet }; }
public ContentResult AddDemandDisagreement(string disagreement, int idEvent, int?idDisagreement) { Disagreement d = new Disagreement(); d.DisagreementOnDate = false; d.DisagreementOnDescription = true; d.DisagreementOnPiece = false; d.IdUser = User.Identity.GetId(); d.Comment = disagreement; d.IdEvent = idEvent; if (idDisagreement != null) { d.Id = idDisagreement.Value; } return(new ContentResult() { Content = JsonHelper.GetJsonString(BLLDisagreements.AddDisagreement(d)), ContentType = "application/json" }); }