public bool savePicture(ImagesEntity model) { var db = new HmsContext(); db.Images.Add(model); return(db.SaveChanges() > 0); }
public bool Save(AccomodationPackage model) { var db = new HmsContext(); db.AccomodationPackages.Add(model); return(db.SaveChanges() > 0); }
public bool Save(Amenity model) { var db = new HmsContext(); db.Amenities.Add(model); return(db.SaveChanges() > 0); }
public bool Save(Booking model) { var db = new HmsContext(); db.Bookings.Add(model); return(db.SaveChanges() > 0); }
public bool DeleteAmenities(AccomodationPackageAmenity model) { var db = new HmsContext(); var removed = db.AccomodationPackageAmenities.Where(x => x.AccomodationPackageId == model.AccomodationPackageId && x.AmenityId == model.AmenityId).FirstOrDefault(); db.Entry(removed).State = System.Data.Entity.EntityState.Deleted; return(db.SaveChanges() > 0); }
public bool Edit(Amenity model) { var db = new HmsContext(); var data = GetById(model.Id); data.Name = model.Name; data.Description = model.Description; db.Entry(data).State = System.Data.Entity.EntityState.Modified; return(db.SaveChanges() > 0); }
public bool Delete(AccomodationPackage model) { using (var db = new HmsContext()) { var data = db.AccomodationPackages.Find(model.Id); db.AccomodationPackageImages.RemoveRange(data.AccomodationPackageImages); db.Entry(data).State = System.Data.Entity.EntityState.Deleted; //db.AccomodationTypes.Remove(data); return(db.SaveChanges() > 0); } }
public bool Delete(Accomodation model) { using (var db = new HmsContext()) { var data = db.Accomodations.Where(x => x.Id == model.Id).FirstOrDefault(); db.AccomodationImages.RemoveRange(data.AccomodationImages); db.Entry(data).State = System.Data.Entity.EntityState.Deleted; //db.AccomodationTypes.Remove(data); return(db.SaveChanges() > 0); } }
public bool Edit(AccomodationPackage model) { var db = new HmsContext(); var exist = db.AccomodationPackages.Find(model.Id); db.AccomodationPackageImages.RemoveRange(exist.AccomodationPackageImages); db.AccomodationPackageImages.AddRange(model.AccomodationPackageImages); db.Entry(exist).CurrentValues.SetValues(model); return(db.SaveChanges() > 0); }
public bool SaveAccomodation(List <Accomodation> accomodations) { var db = new HmsContext(); foreach (var item in accomodations) { var exist = db.Accomodations.Find(item.Id); item.IsAvalable = false; db.Entry(exist).CurrentValues.SetValues(item); //db.Entry(item).State = System.Data.Entity.EntityState.Modified; } return(db.SaveChanges() > 0); }
public bool Save(AccomodationType model) { var db = new HmsContext(); db.AccomodationTypes.Add(model); return db.SaveChanges()> 0; }