コード例 #1
0
        // GET: Quotations

        public ActionResult NewQuote()
        {
            BookingViewModels b = new BookingViewModels();


            return(View());
        }
コード例 #2
0
        // GET: Booking/Create
        public ActionResult Index(string name, string surname, string n)
        {
            try {
                Random gen = new Random();

                int    size  = 10;
                string input = "abcdefghijklmnopqrstuvwxyz0123456789";
                char[] chars = new char[size];
                for (int i = 0; i < size; i++)
                {
                    chars[i] = input[gen.Next(input.Length)];
                }

                BookingViewModels b = new BookingViewModels();
                b.cName    = name;
                b.cSurname = surname;
                b.JobCard  = chars.ToString();
                b.Id       = User.Identity.GetUserId();
                UserManager <ApplicationUser> UserManager =
                    new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(db));
                b.Id = UserManager.FindById(User.Identity.GetUserId()).ToString();
                return(View(b));
            }
            catch
            {
                return(RedirectToAction("Register", "Account"));
            }
        }
コード例 #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            BookingViewModels bookingViewModels = db.BookingViewModels.Find(id);

            db.BookingViewModels.Remove(bookingViewModels);
            db.SaveChanges();
            return(RedirectToAction("Index1"));
        }
コード例 #4
0
        // GET: Booking
        public ActionResult Index(int AccomodationPackageId)
        {
            BookingViewModels model = new BookingViewModels();

            model.Accomodations       = AccomodationServices.Instance.GetAllByPackages(AccomodationPackageId);
            model.AccomodationPackage = AccomodationPackagesServices.Instance.GetByIds(AccomodationPackageId);

            return(View(model));
        }
コード例 #5
0
        public ActionResult Create(BookingViewModels booking)
        {
            if (ModelState.IsValid)
            {
                _balanceSheetService.Create(booking);
            }

            return(View("Index"));
        }
コード例 #6
0
        public void Edit(BookingViewModels model)
        {
            var result = accountBookRepository.Query(m => m.Id.ToString() == model.Id).FirstOrDefault();

            result.Amounttt   = model.Amount;
            result.Categoryyy = (int)model.Kind;
            result.Dateee     = DateTime.Parse(model.Date);
            result.Remarkkk   = model.Remark;
            accountBookRepository.Edit(result);
        }
コード例 #7
0
        public void Create(BookingViewModels booking)
        {
            var thisbooking = new AccountBook();

            thisbooking.Id         = Guid.NewGuid();
            thisbooking.Amounttt   = booking.Amount;
            thisbooking.Categoryyy = (int)booking.Kind;
            thisbooking.Dateee     = Convert.ToDateTime(booking.Date);
            thisbooking.Remarkkk   = booking.Remark;
            accountBookRepository.Create(thisbooking);
        }
コード例 #8
0
        //public ActionResult Index1(int?id)
        //{
        //    var bookings = new BookingViewModels();
        //    bookings.JobCard = db.BookingViewModels
        //        .Include(i => i.cName)
        //        .Include(i => i.JobCard).Include(i => i.Device)
        //        .Include(i => i.Date).Include(i => i.Clerk).Include(i => i.Technician).OrderBy(i => i.Date).ToString();
        //    string userID = User.Identity.GetUserId();
        //       return View(bookings);
        //}
        //// GET: Booking/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BookingViewModels bookingViewModels = db.BookingViewModels.ToList().Find(x => x.BookingID == id);

            if (bookingViewModels == null)
            {
                return(HttpNotFound());
            }
            return(View(bookingViewModels));
        }
コード例 #9
0
        //GET: Booking/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BookingViewModels bookingViewModels = db.BookingViewModels.Find(id);

            if (bookingViewModels == null)
            {
                return(HttpNotFound());
            }
            return(View(bookingViewModels));
        }
コード例 #10
0
        public JsonResult Check(BookingViewModels models)
        {
            JsonResult json    = new JsonResult();
            Booking    booking = new Booking();
            var        result  = false;

            int t = DateTime.Compare(models.FromDate, DateTime.Now);
            int y = DateTime.Compare(models.Duration, models.FromDate);

            if (t > 0 && y > 0)
            {
                var accomodation = AccomodationServices.Instance.GetAllByPackages(models.AccomodationPackageId);
                var a            = new Accomodation();
                List <Accomodation> accomodations = new List <Accomodation>();
                for (int i = 0; i < models.TotalRooms; i++)
                {
                    foreach (var item in accomodation)
                    {
                        a = BookingServices.Instance.Check(item.Id, models.Duration, models.FromDate);
                        if (a != null)
                        {
                            accomodations.Add(a);
                        }
                    }
                }
                if (accomodations == null || accomodations[0] == null || accomodations.Count() <= models.TotalRooms)
                {
                    result = false;
                }
                else
                {
                    result = true;
                }
            }
            else
            {
                result = false;
            }
            if (result)
            {
                json.Data = new { Success = true, Message = "Room is Available" };
            }
            else
            {
                json.Data = new { Success = false, Message = "Room is not Available" };
            }
            return(json);
        }
コード例 #11
0
        // GET: Booking/Edit/5
        public ActionResult Edit(int?id)
        {
            BookingViewModels b = new BookingViewModels();


            b.Id = User.Identity.GetUserId();
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var bookingViewModels = db.BookingViewModels.ToList().Find(x => x.BookingID == id);

            if (bookingViewModels == null)
            {
                return(HttpNotFound());
            }
            return(View(bookingViewModels));
        }
コード例 #12
0
 public ActionResult Edit([Bind(Include = "BookingID,cName,cSurname,IDNumber,Address,TelNo,Device")] BookingViewModels model)
 {//The script is updating but removing the Id field, tried adding Id on the include but got an error
     if (ModelState.IsValid)
     {
         var booking = new BookingViewModels();
         booking.cName         = model.cName;
         booking.cSurname      = model.cSurname;
         booking.IDNumber      = model.IDNumber;
         booking.JobCard       = model.JobCard;
         booking.TelNo         = model.TelNo;
         booking.Address       = model.Address;
         booking.Device        = model.Device;
         booking.Id            = User.Identity.GetUserId();
         db.Entry(model).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index1"));
     }
     return(View(model));
 }
コード例 #13
0
        public ActionResult NewBooking(string name, string surname, string n)
        {
            try
            {
                BookingViewModels b = new BookingViewModels();
                b.cName    = name;
                b.cSurname = surname;

                b.Id = User.Identity.GetUserId();
                UserManager <ApplicationUser> UserManager =
                    new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(db));
                b.Id = UserManager.FindById(User.Identity.GetUserId()).ToString();
                return(View(b));
            }
            catch
            {
                return(RedirectToAction("Register", "Account"));
            }
        }
コード例 #14
0
        public ActionResult NewBooking([Bind(Include = "BookingID,cName,cSurname,IDNumber,Address,TelNo,Device,Id")] BookingViewModels model)
        {
            Random gen = new Random();

            int    size  = 10;
            string input = "abcdefghijklmnopqrstuvwxyz0123456789";

            char[] chars = new char[size];
            for (int i = 0; i < size; i++)
            {
                chars[i] = input[gen.Next(input.Length)];
            }
            model.JobCard = chars.ToString();

            //long idNo = Convert.ToInt32(model.IDNumber);
            //if (idNo <= 0 && idNo >= 14)
            //{
            //    ViewBag.Error = "Invalid Identity Number";
            //}
            if (ModelState.IsValid)
            {
                var booking = new BookingViewModels();
                booking.JobCard  = model.JobCard;
                booking.cName    = model.cName;
                booking.cSurname = model.cSurname;
                booking.IDNumber = model.IDNumber;
                booking.JobCard  = model.JobCard;
                booking.TelNo    = model.TelNo;
                booking.Address  = model.Address;
                booking.Device   = model.Device;
                booking.Id       = User.Identity.GetUserId();
                db.BookingViewModels.Add(booking);
                db.SaveChanges();
                return(RedirectToAction("Index1"));
            }

            return(View(model));
        }
コード例 #15
0
        public ActionResult Index(string searchString)
        {
            try
            {
                Quotation         q   = new Quotation();
                BookingViewModels bID = new BookingViewModels();
                q.Id       = Convert.ToInt32(User.Identity.GetUserId());
                q.IDNumber = bID.IDNumber;

                var booking = from b in db.BookingViewModels
                              select b;

                if (!String.IsNullOrEmpty(searchString))
                {
                    booking = booking.Where(x => x.Id.Contains(searchString));
                }
                q.IDNumber = User.Identity.GetUserId();
                return(View(db.quotation.Where(x => x.IDNumber == q.IDNumber)));
            }
            catch
            {
                return(RedirectToAction("Register", "Account"));
            }
        }
コード例 #16
0
        // GET: Customer/Details/5

        public ActionResult Profile(string name, string surname, int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            try {
                BookingViewModels model = new BookingViewModels();
                Customer          p     = new Customer();
                p.Name    = name;
                p.Surname = surname;

                p.Id = User.Identity.GetUserId();
                UserManager <ApplicationUser> UserManager =
                    new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(db));
                p.Id = UserManager.FindById(User.Identity.GetUserId()).ToString();
                id   = Convert.ToInt16(p.Id);
                var booking = new BookingViewModels();
                booking.cName    = model.cName;
                booking.cSurname = model.cSurname;
                booking.IDNumber = model.IDNumber;

                booking.TelNo   = model.TelNo;
                booking.Address = model.Address;
                booking.Device  = model.Device;



                return(View(p));
            }
            catch
            {
                return(ViewBag.Message());
            }
        }
コード例 #17
0
        public void Delete(BookingViewModels model)
        {
            var result = accountBookRepository.Query(m => m.Id.ToString() == model.Id).FirstOrDefault();

            accountBookRepository.Delete(result);
        }
コード例 #18
0
 public ActionResult Edit(BookingViewModels model)
 {
     _balanceSheetService.Edit(model);
     return(RedirectToAction("Index", "Home", new { area = "" }));
 }
コード例 #19
0
        public JsonResult Index(BookingViewModels models)
        {
            JsonResult json    = new JsonResult();
            Booking    booking = new Booking();

            var result = false;

            if (models.Id > 0)
            {
            }
            else
            {
                var accomodation = AccomodationServices.Instance.GetAllByPackages(models.AccomodationPackageId);
                // accomodation = accomodation.OrderBy(x => x.Id).Where(x => x.IsAvalable).Take(models.TotalRooms).ToList();
                var a = new Accomodation();
                List <Accomodation> accomodations = new List <Accomodation>();
                foreach (var item in accomodation)
                {
                    for (int i = 0; i < models.TotalRooms; i++)
                    {
                        a = BookingServices.Instance.Check(item.Id, models.Duration, models.FromDate);
                        if (a != null)
                        {
                            accomodations.Add(a);
                        }
                    }
                }



                if (accomodations[0] == null || accomodations.Count() <= models.TotalRooms)
                {
                    result = false;
                }

                else
                {
                    if (accomodations != null)
                    {
                        accomodations = accomodation.OrderBy(x => x.Id).Take(models.TotalRooms).ToList();
                    }
                    else
                    {
                        accomodations = accomodations.OrderBy(x => x.Id).Take(models.TotalRooms).ToList();
                    }
                    booking.FromDate = models.FromDate;
                    booking.EndDate  = models.Duration;
                    string userId = User.Identity.GetUserId();
                    booking.UserId       = userId;
                    booking.BookingUsers = new List <BookingUsers>();
                    booking.BookingUsers.AddRange(accomodations.Select(x => new BookingUsers()
                    {
                        AccomodationId = x.Id
                    }));
                    result = BookingServices.Instance.Save(booking);
                }
            }
            if (result)
            {
                json.Data = new { Success = true, Message = "Your Hotel Room is Booked" };
            }
            else
            {
                json.Data = new { Success = false, Message = "Unable To Book Hotel Room" };
            }
            return(json);
        }