예제 #1
0
        private void CustomerDetail_Load(object sender, EventArgs e)
        {
            cityCB.DataSource    = CityLogic.GetAllCities();
            cityCB.DisplayMember = "Name";
            foreach (City item in cityCB.Items)
            {
                if (item.NameZip == _customer.City.NameZip)
                {
                    cityCB.SelectedItem = item;
                    break;
                }
            }

            cityCB.SelectedItem = _customer.City;

            nameTBox.Text            = _customer.Name;
            surenameTBox.Text        = _customer.Surename;
            perNumTBox.Text          = _customer.PersonalNumber;
            phoneTBox.Text           = _customer.Phone;
            emailTBox.Text           = _customer.Email;
            streetTBox.Text          = _customer.Street;
            houseNumTBox.Text        = _customer.HouseNumber;
            regDate.Text             = _customer.RegistrationDate.ToShortDateString();
            distilledVolumeTBox.Text = _customer.DistilledVolume.ToString("0.00");

            customerReservationList.DataSource = ReservationLogic.PendingReservations(_customer.Id);
        }
예제 #2
0
        public ReservationForm()
        {
            InitializeComponent();

            _ReservationLogic = new ReservationLogic();
            _ReservationLogic.CreateDB();
            dd_arrivingHour.Text   = "21";
            dd_arrivingMinute.Text = "00";

            // Adds 0 till 23 hours to the combobox with the reservation time
            for (int i = 0; i <= 23; i++)
            {
                if (i < 10)
                {
                    dd_arrivingHour.Items.Add("0" + i);
                }
                else
                {
                    dd_arrivingHour.Items.Add(i);
                }
            }

            for (int i = 0; i < 60; i += 15)
            {
                if (i == 0)
                {
                    dd_arrivingMinute.Items.Add("00");
                }
                else
                {
                    dd_arrivingMinute.Items.Add(i);
                }
            }
        }
예제 #3
0
        public IActionResult ViewReservations()
        {
            List <Reservation> reservations = ReservationLogic.getAllReservations(_context);

            ViewBag.reservations = reservations;
            return(View());
        }
        public async Task <IActionResult> GetByCustomer(int customerId)
        {
            var list = await ReservationLogic.GetByCustomerId(GetToken(), GetDepartmentCode(), customerId);

            if (!list.Any())
            {
                return(NotFound());
            }
            return(Ok(list));
        }
예제 #5
0
        public async Task <JsonResult> GetTimeSlots(int guests, string date)
        {
            DateTime  dt        = DateTime.ParseExact(date, "MM/dd/yyyy", CultureInfo.InvariantCulture);
            TimeSlots timeslots = new TimeSlots(dt);

            foreach (TimeSlot slot in timeslots.slots)
            {
                slot.isAvailable = ReservationLogic.isAvailable(_context, guests, ReservationLogic.getTableCount(_context), slot);
            }
            return(Json(timeslots.slots));
        }
        public async Task <IActionResult> Create([FromBody] Models.Reservations.Reservation reservations)
        {
            if (!await PublicAuthLogic.CheckAccessToken(GetAccessToken(), GetDepartmentCode()))
            {
                return(Unauthorized());
            }

            var list = await ReservationLogic.PublicCreate(reservations, GetDepartmentCode());

            return(Ok(list));
        }
예제 #7
0
        public IActionResult ReservationList()
        {
            ShowLoggedUser();
            int customerId = _userSession.GetLoggedUser(HttpContext).User.Id;

            ViewData["PendingReservations"]  = ReservationLogic.PendingReservations(customerId);
            ViewData["FinishedReservations"] = ReservationLogic.FinishedReservations(customerId);


            return(View());
        }
예제 #8
0
        public IActionResult ReservationList()
        {
            SetViewData();
            if (!UserAllowed())
            {
                ViewData["Warning"] = "Neautorizovaný přístup.";
                return(View("Warning"));
            }

            ViewData["reservationDic"] = ReservationLogic.GetReservationByDayInPeriod(DateTime.Today, DateTime.Today.AddMonths(1));

            return(View());
        }
예제 #9
0
        public IActionResult ReservationDetail(int id)
        {
            SetViewData();
            if (!UserAllowed())
            {
                ViewData["Warning"] = "Neautorizovaný přístup.";
                return(View("Warning"));
            }

            if (ReservationLogic.GetReservation(id) is DataLayerNetCore.Entities.Reservation r)
            {
                return(View(r));
            }
            else
            {
                ViewData["Warning"] = "Neexistující rezervace.";
                return(View("Warning"));
            }
        }
예제 #10
0
        public IActionResult ConfirmReservation(ReservationViewModel reservation)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Error"));
            }
            TimeSlot slot = new TimeSlot();

            slot.FullDate = reservation.ReservationDate;
            //Ensure reservation is still available
            if (ReservationLogic.isAvailable(_context, reservation.GuestAmount, ReservationLogic.getTableCount(_context), slot))
            {
                //Convert out viewmodel to entity model
                Reservation EntityReservation = new Reservation();
                EntityReservation.ReservationId   = Guid.NewGuid().ToString();
                EntityReservation.BookingUser     = reservation.User;
                EntityReservation.GuestAmount     = reservation.GuestAmount;
                EntityReservation.ReservationTime = reservation.ReservationDate;
                EntityReservation.Menu            = reservation.Menu;
                EntityReservation.Drink           = reservation.Drink;

                List <Table> desiredTables = ReservationLogic.reserveTables(_context, reservation.GuestAmount, slot);
                foreach (Table table in desiredTables)
                {
                    TableReservation tableReservation = new TableReservation();
                    tableReservation.Reservation   = EntityReservation;
                    tableReservation.ReservationId = EntityReservation.ReservationId;
                    tableReservation.Table         = table;
                    tableReservation.TableId       = table.TableId;
                    EntityReservation.TableReservations.Add(tableReservation);
                }

                //Save entity to db
                _context.Add(EntityReservation);
                _context.SaveChanges();
                return(View());
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
예제 #11
0
        public IActionResult NewReservation(ReservationForm model, string returnUrl = null)
        {
            ShowLoggedUser();
            ViewData["Materials"] = MaterialLogic.MaterialNames();

            if (ModelState.IsValid)
            {
                model.AvaibleDateTime = ReservationLogic.IsDateTimeAvaible(model.RequstedDate);

                if (model.RequstedDate < DateTime.Now)
                {
                    model.AvaibleDateTime = false;
                }

                if (model.AvaibleDateTime)
                {
                    try
                    {
                        ReservationLogic.CreateReservation(
                            _userSession.GetLoggedUser(HttpContext).User.Id,
                            model.RequstedDate,
                            model.Material,
                            model.MaterialAmount);

                        return(RedirectToAction("ReservationList"));
                    }
                    catch (DatabaseException e)
                    {
                        return(View("Error", new ErrorViewModel()
                        {
                            RequestId = e.Message
                        }));
                    }
                }
            }


            return(View(model));
        }
예제 #12
0
 public IActionResult Remove(string Id)
 {
     ReservationLogic.removeById(_context, Id);
     return(RedirectToAction("ViewReservations"));
 }
예제 #13
0
 public ReservationLogicTests()
 {
     reservationLogic = new ReservationLogic(DBContextFactory.GetMockedDbContext());
 }
        public async Task <IActionResult> Update([FromBody] Models.Reservations.Reservation reservation)
        {
            var isSuccess = await ReservationLogic.Update(GetToken(), reservation);

            return(Ok(isSuccess));
        }
        public async Task <IActionResult> GetList(bool isApproval = false)
        {
            var list = await ReservationLogic.GetList(GetDepartmentCode(), isApproval);

            return(Ok(list));
        }
예제 #16
0
 public ReservationsController(ReservationLogic logic)
 {
     reservationLogic = logic;
 }