public ActionResult UpdateRequest([DataSourceRequest] DataSourceRequest request, TmcOutViewModel dictionary) { TmcOut d = db.TmcOuts.First(o => o.Id == dictionary.Id); d.StateType = dictionary.StateType; d.Note = dictionary.Note; d.OutTypeDicId = dictionary.OutTypeDicId; d.StorageDicId = dictionary.StorageDicId; d.OwnerEmployeeId = dictionary.OwnerEmployeeId; d.Rack = dictionary.Rack; d.Safe = dictionary.Safe; db.SaveChanges(); var newDictionary = db.TmcOutViews.First(o => o.Id == d.Id); dictionary.OwnerEmployeeValue = newDictionary.OwnerEmployeeValue; dictionary.StateTypeValue = newDictionary.StateTypeValue; return(Json(new[] { dictionary }.ToDataSourceResult(request, ModelState))); }
public ActionResult CreateRequest([DataSourceRequest] DataSourceRequest request, TmcOutViewModel dictionary) { TmcOut tmcOut = new TmcOut() { Id = Guid.NewGuid(), StateType = dictionary.StateType, Note = dictionary.Note, OutTypeDicId = dictionary.OutTypeDicId, CreatedDate = DateTime.Now, CreatedEmployeeId = UserHelper.GetCurrentEmployee().Id, StorageDicId = dictionary.StorageDicId, OwnerEmployeeId = dictionary.OwnerEmployeeId, Safe = dictionary.Safe, Rack = dictionary.Rack, }; db.TmcOuts.Add(tmcOut); db.SaveChanges(); dictionary.Id = tmcOut.Id; var newDictionary = db.TmcOutViews.First(o => o.Id == tmcOut.Id); dictionary.OwnerEmployeeValue = newDictionary.OwnerEmployeeValue; dictionary.StateTypeValue = newDictionary.StateTypeValue; dictionary.OutTypeDicValue = newDictionary.OutTypeDicValue; dictionary.TmcOutId = tmcOut.Id; return(Json(new[] { dictionary }.ToDataSourceResult(request, ModelState))); }