public JsonResult Delete(AccomodationActionViewModel model) { JsonResult jsonResult = new JsonResult(); var result = false; var accomodation = accomodationService.GetAccomodationsById(model.Id); result = accomodationService.DeleteAccomodations(accomodation); if (result) { jsonResult.Data = new { Success = true }; } else { jsonResult.Data = new { Success = false, Message = "Unable to perform action on Accomodation!!!" }; } return(jsonResult); }
public JsonResult Action(Accomodation model, bool isDeleted = false) { JsonResult json = new JsonResult(); var result = false; if (model.Id > 0 && isDeleted == false) { //edit here result = accomodationService.UpdateAccomodations(model); } else if (model.Id > 0 && isDeleted == true) { //delete here result = accomodationService.DeleteAccomodations(model.Id); } else { //first create object then add Accomodation accomodation = new Accomodation(); accomodation.AccomodationPackageId = model.AccomodationPackageId; accomodation.Name = model.Name; accomodation.Description = model.Description; result = accomodationService.SaveAccomodations(accomodation); } if (result) { json.Data = new { success = true }; } else { json.Data = new { success = false, Messag = "Unable to Perform Operation." }; } return(json); }