public ActionResult MaterialOutItemSetup(MaterialOutItemModel model) { MaterialOutItem materialOutItem = db.MaterialOutItems.Where(a => a.MaterialOutItemId.Equals(model.MaterialOutItemId)).FirstOrDefault(); if (materialOutItem == null) { MaterialOutItem newMaterialOutItemadd = new MaterialOutItem(); newMaterialOutItemadd.Name = model.Name; newMaterialOutItemadd.CreateDate = DateTime.Now; //newMaterialOutItemadd.IsActive = model.IsActive; newMaterialOutItemadd.IsActive = true; db.MaterialOutItems.Add(newMaterialOutItemadd); db.SaveChanges(); ModelState.Clear(); model = null; this.AddNotification("Thats great! Successfully Saved.", NotificationType.SUCCESS); } else { materialOutItem.Name = model.Name; //materialOutItem.IsActive = model.IsActive; materialOutItem.IsActive = true; db.SaveChanges(); model = null; this.AddNotification("Thats great! Successfully Edited.", NotificationType.SUCCESS); } return(RedirectToAction("MaterialOutItemList")); }
public ActionResult MaterialOutItemEditView(int MaterialOutItemId) { MaterialOutItemModel model = new MaterialOutItemModel(); MaterialOutItem newFitCat = db.MaterialOutItems.Where(a => a.MaterialOutItemId.Equals(MaterialOutItemId)).FirstOrDefault(); if (newFitCat != null) { model.Name = newFitCat.Name; model.IsActive = newFitCat.IsActive.Value; } return(View("MaterialOutItemSetup", model)); }