public ActionResult LoadNewGarageInfo(Guid id, Guid?garageInfoId = null, Guid?category = null) { Guid garageInfoid = garageInfoId.GetValueOrDefault(); Model.GarageInfo FGarageDetails = fleetservice.GetGarageInfoById(garageInfoid); var model = garageInfoId == null ? new GarageInfo() : FGarageDetails; model.Currencies = new SelectList(orService.GetCurrencies(), "Id", "ShortName"); model.Suppliers = new SelectList(poService.GetSuppliers(), "Id", "Name"); model.MileageCategory = new SelectList(fleetservice.GetCheckListCategory(), "Id", "Name"); model.FleetId = id; if (category != null) { model.ChecKListCatId = category; } if (FGarageDetails != null) { CheckListCategory CListCat = fleetservice.GetCheckListCatByGarageInfo(FGarageDetails); model.ChecKListCatId = CListCat != null ? CListCat.Id : (Guid?)null; } ViewBag.Action = garageInfoId == null ? "SaveNewGarageInfo" : "EditGarageInfo"; return(View("LoadNewGarageInfo", model)); }
public ActionResult DeleteCategory(Guid CatId) { using (var db = new SCMSEntities()) { var clc = new CheckListCategory() { Id = CatId }; db.CheckListCategories.Attach(clc); ((IObjectContextAdapter)db).ObjectContext.ObjectStateManager.ChangeObjectState(clc, System.Data.EntityState.Deleted); db.SaveChanges(); } SessionData.CurrentSession.CheckListCategoryList = null; SessionData.CurrentSession.ServiceCheckListList = null; return(ListView()); }
public ActionResult CreateEditCatory(CheckListCategory entity) { using (var context = new SCMSEntities()) { if (entity.Id.Equals(Guid.Empty)) { entity.Id = Guid.NewGuid(); entity.IssueDate = DateTime.Now; entity.CountryprogrammeId = countryProg.Id; context.CheckListCategories.Add(entity); } else { context.CheckListCategories.Attach(entity); ((IObjectContextAdapter)context).ObjectContext.ObjectStateManager.ChangeObjectState(entity, System.Data.EntityState.Modified); } context.SaveChanges(); } SessionData.CurrentSession.CheckListCategoryList = null; SessionData.CurrentSession.ServiceCheckListList = null; return(ListView()); }