public bool Save(AccomodationPackage model) { var db = new HmsContext(); db.AccomodationPackages.Add(model); return(db.SaveChanges() > 0); }
public List <ImagesEntity> GetPicBtIds(List <int> picIds) { using (var db = new HmsContext()) { return(picIds.Select(x => db.Images.Find(x)).ToList()); } }
public List <AccomodationImages> GetPicByAccomodationId(int Id) { var db = new HmsContext(); var v = db.Accomodations.Find(Id).AccomodationImages.ToList(); return(v); }
public List <AccomodationPackage> GetAllByAccomodationId(int accomdationTypeId) { using (var db = new HmsContext()) { return(db.AccomodationPackages.Where(x => x.AccomodationTypeId == accomdationTypeId).ToList()); } }
public AccomodationPackage GetById(int Id) { using (var db = new HmsContext()) { return(db.AccomodationPackages.Find(Id)); } }
public bool savePicture(ImagesEntity model) { var db = new HmsContext(); db.Images.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 List<AccomodationType> SearchAllAccomodationTypes(string search) { var db = new HmsContext(); var accomodationType = db.AccomodationTypes.AsQueryable(); if(!string.IsNullOrEmpty(search)) { accomodationType= accomodationType.Where(a => a.Name.ToLower().Contains(search.ToLower())); } return accomodationType.ToList(); }
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(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 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 List <Amenity> SearchAllAmenities(string search) { var db = new HmsContext(); var amenity = db.Amenities.AsQueryable(); if (!string.IsNullOrEmpty(search)) { amenity = amenity.Where(a => a.Name.ToLower().Contains(search.ToLower())); } return(amenity.ToList()); }
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 Booking GetBookingById(string userId, int Id) { var db = new HmsContext(); var v = db.Bookings.Find(Id); if (v.UserId == userId) { return(v); } else { return(null); } }
public int SearchAllAccomodationPackagesCount(string search, int?accomodationTypeId) { var db = new HmsContext(); var accomodationPackes = db.AccomodationPackages.AsQueryable(); if (!string.IsNullOrEmpty(search)) { accomodationPackes = accomodationPackes.Where(a => a.Name.ToLower().Contains(search.ToLower())); } if (accomodationTypeId.HasValue && accomodationTypeId.Value > 0) { accomodationPackes = accomodationPackes.Where(a => a.AccomodationTypeId == accomodationTypeId.Value); } return(accomodationPackes.Count()); }
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 List <AccomodationPackage> SearchAllAccomodationPackages(string search, int?accomodationTypeId, int pageNo, int pageSize) { var db = new HmsContext(); var accomodationPackes = db.AccomodationPackages.AsQueryable(); if (!string.IsNullOrEmpty(search)) { accomodationPackes = accomodationPackes.Where(a => a.Name.ToLower().Contains(search.ToLower())); } if (accomodationTypeId.HasValue && accomodationTypeId.Value > 0) { accomodationPackes = accomodationPackes.Where(a => a.AccomodationTypeId == accomodationTypeId.Value); } return(accomodationPackes.OrderBy(x => x.Name).Skip((pageNo - 1) * pageSize). Take(pageSize).ToList()); }
public bool IsExist(int AccomodationId) { var db = new HmsContext(); try { var T = db.BookingUsers.Where(z => z.AccomodationId == AccomodationId).ToList(); var v = db.BookingUsers.Where(z => z.AccomodationId == AccomodationId).OrderByDescending(x => x.Id).First(); var Check = db.Bookings.Find(v.BookingId); if (DateTime.Now > Check.EndDate) { return(false); } else { return(true); } } catch (Exception) { return(false); } }
public Accomodation Check(int id, DateTime duration, DateTime fromDate) { using (var db = new HmsContext()) { Accomodation accomodation = new Accomodation(); var bookings = db.BookingUsers.Where(z => z.AccomodationId == id).ToList(); foreach (var item in bookings) { var book = db.Bookings.Find(item.BookingId); if (book.FromDate == fromDate || book.EndDate == duration) { accomodation = null; } else { accomodation = item.Accomodation; } } return(accomodation); } }
public List <AccomodationPackageImage> GetPicByAccomodationId(int Id) { var db = new HmsContext(); return(db.AccomodationPackages.Find(Id).AccomodationPackageImages.ToList()); }
public List <Booking> Bookings() { var db = new HmsContext(); return(db.Bookings.OrderByDescending(x => x.Id).ToList()); }
public List <AccomodationPackage> GetAllAccomodationPackages() { var db = new HmsContext(); return(db.AccomodationPackages.ToList()); }
public Amenity GetById(int Id) { var db = new HmsContext(); return(db.Amenities.Find(Id)); }
public AccomodationPackage GetByIds(int Id) { var db = new HmsContext(); return(db.AccomodationPackages.Find(Id)); }
public List <Booking> GetByUserId(string userId) { var db = new HmsContext(); return(db.Bookings.Where(x => x.UserId == userId).ToList()); }
public AccomodationType GetById(int Id) { var db = new HmsContext(); return db.AccomodationTypes.Find(Id); }
public List <AccomodationPackageAmenity> CurrentAmenities(int id) { var db = new HmsContext(); return(db.AccomodationPackageAmenities.Where(x => x.AccomodationPackageId == id).ToList()); }
public List <Accomodation> GetAllaccomodations() { var db = new HmsContext(); return(db.Accomodations.OrderBy(x => x.Id).Take(9).ToList()); }