public ActionResult Action(int?ID, bool isDelete = false) { AccomodationTypesActionViewModel model = new AccomodationTypesActionViewModel(); ViewBag.isDelete = isDelete; if (ID.HasValue && isDelete) { //delete here AccomodationType accomodationType = accomodationTypesService.GetAccomodationTypeById(ID); model.Id = accomodationType.Id; model.Name = accomodationType.Name; model.Description = accomodationType.Description; } else if (ID.HasValue && isDelete == false) { //edit here AccomodationType accomodationType = accomodationTypesService.GetAccomodationTypeById(ID); model.Id = accomodationType.Id; model.Name = accomodationType.Name; model.Description = accomodationType.Description; } else { //new entry } return(PartialView("_Action", model)); }
public ActionResult Action(int?id) { AccomodationTypesActionViewModel model = new AccomodationTypesActionViewModel(); if (id.HasValue) { var getThisAccomodationType = accomodationTypesService.GetAccomodationTypeById(id.Value); model.Id = getThisAccomodationType.Id; model.Name = getThisAccomodationType.Name; model.Description = getThisAccomodationType.Description; } return(PartialView("_Action", model)); }
// GET: Accomodation public ActionResult Index(int accomodationTypeId, int?accomodationPacakageId) { AccomodationViewModel model = new AccomodationViewModel(); model.AccomodationPackages = accomodationPackagesService.GetAllAccomodationPackagesbyAccomodationType(accomodationTypeId); model.AccomodationType = accomodationTypesService.GetAccomodationTypeById(accomodationTypeId); model.selectedAccomodationPackageId = accomodationPacakageId.HasValue ? accomodationPacakageId : model.AccomodationPackages.FirstOrDefault() != null?model.AccomodationPackages.FirstOrDefault().Id : 0; model.Accomodations = accomodationService.GetAllAccomodationsByAccomodationPackage(model.selectedAccomodationPackageId.Value); return(View(model)); }