public ActionResult Edit(RockUtilTransfer model) { if (!((model.LotQuantity != null) && ((float)model.LotQuantity > 0))) { ModelState.AddModelError("LotQuantity", "Некорректный вес - должен быть больше 0"); } if (ModelState.IsValid) { RockUtilTransfer transfer = _cdb.RockUtilTransfers.Find(model.ID); transfer.IsValid = true; transfer.Status = 3; transfer.LasEditDateTime = DateTime.Now; transfer.OperatorName = User.Identity.Name; _cdb.Entry(transfer).State = EntityState.Modified; _cdb.SaveChanges(); model.InheritedFrom = transfer.ID; model.ID = "R" + model.EquipID + (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; model.OperatorName = User.Identity.Name; string name = Request.UserHostName; model.LasEditDateTime = DateTime.Now; model.IsValid = false; model.Status = 2; _cdb.RockUtilTransfers.Add(model); _cdb.SaveChanges(); return(RedirectToAction("Index")); } @ViewBag.Title = "Редактирование данных утилизации породы"; return(View("Edit", model)); }
public ActionResult Add(int?rockUtilID, string name) { if (rockUtilID == null) { return(HttpNotFound()); } string userName = User.Identity.Name ?? ""; var model = new RockUtilTransfer(); model.Equip = EquipmentProvider.GetUserAuthorizedEquipment <RockUtil>(_cdb, User.Identity).Where(s => s.ID == rockUtilID).Single(); model.EquipID = rockUtilID; model.ID = "R" + rockUtilID + (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; model.TransferTimeStamp = System.DateTime.Now; model.LasEditDateTime = DateTime.Now; ViewBag.Name = name; @ViewBag.Title = "Ввод данных утилизации породы"; return(View("Add", model)); }
public ActionResult Add(RockUtilTransfer model, string name) { string userName = User.Identity.Name ?? ""; if (!((model.LotQuantity != null) && ((float)model.LotQuantity > 0))) { ModelState.AddModelError("LotQuantity", "Некорректный вес - должен быть больше 0"); } if (ModelState.IsValid) { model.LasEditDateTime = DateTime.Now; model.IsValid = false; model.Status = 1; model.OperatorName = User.Identity.Name; _cdb.RockUtilTransfers.Add(model); _cdb.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Name = name; @ViewBag.Title = "Ввод данных утилизации породы"; return(View("Add", model)); }