public AccomodationCreateModel(Accomodations model) { ID = model.ID; Name = model.Name; Description = model.Description; IsActive = model.IsActive; AccomodationPackageID = model.AccomodationPackageID; }
public bool SaveAccomodations(Accomodations obj) { using (var _context = new HMSvContext()) { if (obj.ID == 0) { obj.IsActive = true; _context.Accomodation.Add(obj); } else { var accomodation = _context.Accomodation.Single(c => c.ID == obj.ID); accomodation.Name = obj.Name; accomodation.Description = obj.Description; accomodation.IsActive = true; accomodation.AccomodationPackageID = obj.AccomodationPackageID; } return(_context.SaveChanges() > 0); } }
public JsonResult Save(Accomodations model) { var json = new JsonResult(); var error = ""; var result = false; try { result = _service.SaveAccomodations(model); } catch (Exception exp) { error = exp.Message + " " + exp.InnerException.Message; } if (result) { json.Data = new { Success = true, Link = Url.Action("Listing", "Accomodation"), Message = Status.Successfull }; } else { json.Data = new { Success = false, Link = Url.Action("Listing", "Accomodation"), Message = Status.Failed + " " + error }; } return(json); }