public ActionResult MaterialOutPartySetup(MaterialOutPartyModel model) { MaterialOutParty materialOutParty = db.MaterialOutParties.Where(a => a.MatOutPartyId.Equals(model.MatOutPartyId)).FirstOrDefault(); if (materialOutParty == null) { MaterialOutParty newMaterialOutPartyadd = new MaterialOutParty(); newMaterialOutPartyadd.Name = model.Name; newMaterialOutPartyadd.OpeningBalance = model.OpeningBalance; newMaterialOutPartyadd.CreateDate = DateTime.Now; //newMaterialOutPartyadd.IsActive = model.IsActive; newMaterialOutPartyadd.IsActive = true; db.MaterialOutParties.Add(newMaterialOutPartyadd); db.SaveChanges(); ModelState.Clear(); model = null; this.AddNotification("Thats great! Successfully Saved.", NotificationType.SUCCESS); } else { materialOutParty.Name = model.Name; materialOutParty.OpeningBalance = model.OpeningBalance; //materialOutParty.IsActive = model.IsActive; materialOutParty.IsActive = true; db.SaveChanges(); model = null; this.AddNotification("Thats great! Successfully Edited.", NotificationType.SUCCESS); } return(RedirectToAction("MaterialOutPartyList")); }
public ActionResult MaterialOutPartyEditView(int MatOutPartyId) { MaterialOutPartyModel model = new MaterialOutPartyModel(); MaterialOutParty newFitCat = db.MaterialOutParties.Where(a => a.MatOutPartyId.Equals(MatOutPartyId)).FirstOrDefault(); if (newFitCat != null) { model.Name = newFitCat.Name; model.OpeningBalance = newFitCat.OpeningBalance.Value; model.IsActive = newFitCat.IsActive.Value; } return(View("MaterialOutPartySetup", model)); }