public ActionResult GmoCapexes_Update([DataSourceRequest] DataSourceRequest request, GmoCapex gmoCapex, string userID) { int _userID = userID.ToInt(); var _userInfo = db.peAppUsers.Where(u => u.ID.Equals(_userID)).Select(u => new { u.Dept, u.LoginName }).FirstOrDefault(); if (ModelState.IsValid) { var entity = new GmoCapex { Id = gmoCapex.Id, AnnualBudgetId = gmoCapex.AnnualBudgetId, DeptName = gmoCapex.DeptName, PrjLeader = gmoCapex.PrjLeader, PrjName = gmoCapex.PrjName, YusuanMoney = gmoCapex.YusuanMoney, BudgetQuarter = gmoCapex.BudgetQuarter, Status = gmoCapex.Status, JinduMiaoshu = gmoCapex.JinduMiaoshu, CapexId = gmoCapex.CapexId, ShenqingMoney = gmoCapex.ShenqingMoney, HuiguJieguo = gmoCapex.HuiguJieguo, Inputer = gmoCapex.Inputer, //InputDatetime = gmoCapex.InputDatetime, Modifier = _userInfo.LoginName ?? "", ModifyDatetime = DateTime.Now }; db.GmoCapexes.Attach(entity); db.Entry(entity).State = EntityState.Modified; db.SaveChanges(); } return(Json(new[] { gmoCapex }.ToDataSourceResult(request, ModelState))); }
public ActionResult GmoIdelAssets_BatchUpdate([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")] IEnumerable <GmoIdelAsset> gmoIdelAssets, string userID) { int _userID = userID.ToInt(); var _userInfo = db.peAppUsers.Where(u => u.ID.Equals(_userID)).Select(u => new { u.Dept, u.LoginName }).AsNoTracking().FirstOrDefault(); var entities = new List <GmoIdelAsset>(); foreach (var gmoIdelAsset in gmoIdelAssets) { var entity = new GmoIdelAsset { Id = gmoIdelAsset.Id, DeptName = gmoIdelAsset.DeptName, ZicanId = gmoIdelAsset.ZicanId, ZicanName = gmoIdelAsset.ZicanName, Pinpai = gmoIdelAsset.Pinpai, Xinghao = gmoIdelAsset.Xinghao, CunfangDidian = gmoIdelAsset.CunfangDidian, QidongDate = gmoIdelAsset.QidongDate, BeginDate = gmoIdelAsset.BeginDate, Reason = gmoIdelAsset.Reason, Status = gmoIdelAsset.Status, Fuzeren = gmoIdelAsset.Fuzeren, Yuanzhi = gmoIdelAsset.Yuanzhi, LeijiZhejiu = gmoIdelAsset.LeijiZhejiu, JingZhi = gmoIdelAsset.JingZhi, Inputer = _userInfo.LoginName ?? "", //InputDatetime = DateTime.Now, Modifier = "", ModifyDatetime = gmoIdelAsset.ModifyDatetime }; entities.Add(entity); db.GmoIdelAssets.Attach(entity); db.Entry(entity).State = EntityState.Modified; } db.SaveChanges(); return(Json(entities.ToDataSourceResult(request, ModelState))); }