コード例 #1
0
 public Accomodation GetAccomodationId(int Id)
 {
     using (var context = new HMSContext())
     {
         return context.Accomodations.Find(Id);
     }
 }
コード例 #2
0
        public bool SaveAccomodationType(AccomodationType accomodationType)
        {
            var context = new HMSContext();

            context.AccomodationTypes.Add(accomodationType);
            return(context.SaveChanges() > 0);
        }
コード例 #3
0
 public BookingsController(HMSContext context, AccomodationPackagesService accomodationPackagesService
                           , BookingService bookingService)
 {
     _context = context;
     _accomodationPackagesService = accomodationPackagesService;
     _bookingService = bookingService;
 }
コード例 #4
0
        public void UpdateState(List <int> ids, bool status)
        {
            HMSContext context = new HMSContext();

            if (status == true)
            {
                foreach (var t in ids)
                {
                    var obj = context.Accomodations.Find(t);
                    obj.IsHold = true;
                    context.Entry(obj).State = EntityState.Modified;
                    context.SaveChanges();
                }
            }
            else
            {
                foreach (var t in ids)
                {
                    var obj = context.Accomodations.Find(t);
                    obj.IsHold = false;
                    context.Entry(obj).State = EntityState.Modified;
                    context.SaveChanges();
                }
            }
        }
 public EmployeeController()
 {
     _context           = new HMSContext();
     _employeeReposiory = new EFRepository <Employee>(_context);
     _roleReposiory     = new EFRepository <Role>(_context);
     ViewBag.RoleList   = _roleReposiory.Get().ToList();
 }
コード例 #6
0
        //Function edit
        public bool UpdateAccomodationPackage(AccomodationPackage accomodationPackage)
        {
            var context = new HMSContext();

            context.Entry(accomodationPackage).State = System.Data.Entity.EntityState.Modified;
            return(context.SaveChanges() > 0);
        }
コード例 #7
0
 public Accomodation GetAccomodationByID(int ID)
 {
     using (var context = new HMSContext())
     {
         return(context.Accomodations.Find(ID));
     }
 }
コード例 #8
0
        public int TotalAccomodationsReserved()
        {
            HMSContext db = new HMSContext();


            return(db.Bookings.Count(a => a.Status == "Reserved"));
        }
コード例 #9
0
        public int TotalAccomodationsCheckedIn()
        {
            HMSContext db = new HMSContext();


            return(db.Bookings.Count(a => a.Status == "CheckedIn"));
        }
コード例 #10
0
        public bool UpdateAccomodation(Accomodation accomodation)
        {
            var _context = new HMSContext();

            _context.Entry(accomodation).State = System.Data.Entity.EntityState.Modified;
            return(_context.SaveChanges() > 0);
        }
コード例 #11
0
        public int AccomodationsCount()
        {
            HMSContext db = new HMSContext();


            return(db.Accomodations.Count());
        }
コード例 #12
0
        public IEnumerable <Picture> getPicturesByIds(List <int> picIds)
        {
            var context = new HMSContext();

            // find each picIds inside the Picture database
            return(picIds.Select(x => context.Picture.Find(x)));
        }
コード例 #13
0
 public IEnumerable <Pictures> GetPictureByIDs(List <int> pictureIDs)
 {
     using (var context = new HMSContext())
     {
         return(pictureIDs.Select(x => context.Picture.Find(x)).ToList());
     }
 }
コード例 #14
0
        public bool UpdateAccomodationType(AccomodationType accomodationType)
        {
            var context = new HMSContext();

            context.Entry(accomodationType).State = EntityState.Modified;
            return(context.SaveChanges() > 0);
        }
コード例 #15
0
        public bool SavePicture(Picture picture)
        {
            var context = new HMSContext();

            context.Pictures.Add(picture);
            return(context.SaveChanges() > 0);
        }
コード例 #16
0
        public IEnumerable <Booking> ComepleteBookingDetail()
        {
            HMSContext db = new HMSContext();


            return(db.Bookings.ToList());
        }
コード例 #17
0
 public AccomodationsController(HMSContext context, AccomodationPackagesService accomodationPackagesService,
                                AccomodationService accomodationService)
 {
     _context = context;
     this.accomodationPackagesService = accomodationPackagesService;
     this.accomodationService         = accomodationService;
 }
コード例 #18
0
        public List <Message> GetMessages()
        {
            HMSContext db = new HMSContext();


            return(db.Messages.ToList());
        }
コード例 #19
0
        //Function create
        public bool SaveAccomodation(Accomodation accomodation)
        {
            var context = new HMSContext();

            context.Accomodations.Add(accomodation);
            return(context.SaveChanges() > 0);
        }
コード例 #20
0
        public IEnumerable <Accomodation> SearchAccomodations(string searchTerm, int?accomodationPackageID, int page, int recordSize)

        {
            var context = new HMSContext();



            var accomodations = context.Accomodations.AsQueryable();



            if (!string.IsNullOrEmpty(searchTerm))

            {
                accomodations = accomodations.Where(a => a.Name.ToLower().Contains(searchTerm.ToLower()));
            }



            if (accomodationPackageID.HasValue && accomodationPackageID.Value > 0)

            {
                accomodations = accomodations.Where(a => a.AccomodationPackageID == accomodationPackageID.Value);
            }



            var skip = (page - 1) * recordSize;



            return(accomodations.OrderBy(x => x.AccomodationPackageID).Skip(skip).Take(recordSize).ToList());
        }
コード例 #21
0
        public bool UpdateAccommodationType(AccommodationType model)
        {
            var context = new HMSContext();

            context.Entry(model).State = System.Data.Entity.EntityState.Modified;
            return(context.SaveChanges() > 0);
        }
コード例 #22
0
        public int SearchAccomodationsCount(string searchTerm, int?accomodationPackageID)

        {
            var context = new HMSContext();



            var accomodations = context.Accomodations.AsQueryable();



            if (!string.IsNullOrEmpty(searchTerm))

            {
                accomodations = accomodations.Where(a => a.Name.ToLower().Contains(searchTerm.ToLower()));
            }



            if (accomodationPackageID.HasValue && accomodationPackageID.Value > 0)

            {
                accomodations = accomodations.Where(a => a.AccomodationPackageID == accomodationPackageID.Value);
            }



            return(accomodations.Count());
        }
コード例 #23
0
        /// <summary>
        /// Admin Actions in Booking Service
        /// </summary>
        /// <param name="ids"></param>
        /// <param name="status"></param>

        public IEnumerable <Booking> GetAllBookings()
        {
            HMSContext context = new HMSContext();
            var        model   = context.Bookings.ToList();

            return(model);
        }
コード例 #24
0
 public AccomodationPackage GetAccomodationPackageById(int id)
 {
     using (var _context = new HMSContext())
     {
         return(_context.AccomodationPackages.Find(id));
     }
 }
コード例 #25
0
        public IEnumerable <AccomadationPackage> SearchAccomadationPackages(string searchTerm, int?accomadationTypeID, int pageSize, int page) // we cants use 'using' statement with IEnumerable
        {
            var context = new HMSContext();

            var accomadationPackage = context.AccomadationPackage.AsQueryable(); // 'AsQueryable' will allow us to use query on the AccomadationType such as using 'Where' on it

            // find based on searchTerm
            if (!string.IsNullOrEmpty(searchTerm))
            {
                // check if the searchterm exist in the database column Name
                accomadationPackage = accomadationPackage.Where(x => x.Name != null && x.Name.ToLower().Contains(searchTerm.ToLower()));
            }

            // find based on accomadationTypeID
            if (accomadationTypeID.HasValue && accomadationTypeID.Value > 0)
            {
                // check if the searchterm exist in the database column Name
                accomadationPackage = accomadationPackage.Where(x => x.AccomadationTypeID == accomadationTypeID.Value);
            }

            // skip = (1 - 1) * 3 = 0 * 3 = 0
            // skip = (2 - 1) * 3 = 1 * 3 = 3
            // skip = (3 - 1) * 3 = 2 * 3 = 6
            var skip = (page - 1) * pageSize;

            return(accomadationPackage.OrderBy(x => x.AccomadationTypeID).Skip(skip).Take(pageSize).AsEnumerable()); // we have to use the 'sortBy' if we are going to use 'Skip'
        }
コード例 #26
0
        public bool SaveAccomodationPackage(AccomodationPackage accomodationPackage)
        {
            var _context = new HMSContext();

            _context.AccomodationPackages.Add(accomodationPackage);
            return(_context.SaveChanges() > 0);
        }
コード例 #27
0
        public bool DeleteAccomodationType(AccomodationType accomodationType)
        {
            var context = new HMSContext();

            context.Entry(accomodationType).State = System.Data.Entity.EntityState.Deleted;
            return(context.SaveChanges() > 0);
        }
コード例 #28
0
        public bool DeleteAccomodationPackage(AccomodationPackage accomodationPackage)
        {
            var _context = new HMSContext();

            _context.Entry(accomodationPackage).State = System.Data.Entity.EntityState.Deleted;
            return(_context.SaveChanges() > 0);
        }
コード例 #29
0
        public int CountAccomodationByPackage(int?accomodationPackageID)
        {
            var context      = new HMSContext();
            var packageCount = context.Accomodations.Count(a => a.AccomodationPackageId == accomodationPackageID);

            return(packageCount);
        }
コード例 #30
0
 public TechController()
 {
     _context               = new HMSContext();
     _roleRepository        = new EFRepository <Role>(_context);
     _menuRepository        = new EFRepository <Menu>(_context);
     _menuRoleMapRepository = new EFRepository <MenuRoleMap>(_context);
 }