Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ReservasionId,GuestId,RoomId,AdultId,ChildId,RoomQuantityId,ArrivalTime,DepartureDate")] Reservasion reservasion)
        {
            if (id != reservasion.ReservasionId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(reservasion);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ReservasionExists(reservasion.ReservasionId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AdultId"]        = new SelectList(_context.Adult, "AdultId", "NumberOfAdults", reservasion.AdultId);
            ViewData["ChildId"]        = new SelectList(_context.Child, "ChildId", "NumberOfChild", reservasion.ChildId);
            ViewData["GuestId"]        = new SelectList(_context.Guest, "GuestId", "FullName", reservasion.GuestId);
            ViewData["RoomId"]         = new SelectList(_context.Room, "RoomId", "RoomTypeName", reservasion.RoomId);
            ViewData["RoomQuantityId"] = new SelectList(_context.RoomQuantity, "RoomQuantityId", "NumberOfRoom", reservasion.RoomQuantityId);
            return(View(reservasion));
        }
        static void Main(string[] args)
        {
            //Run NestedConditionalRefactor Code
            var goldCustomer1 = new CleanCodeExercises.NestedConditionalsRefactor.Customer()
            {
                LoyaltyPoints = 120
            };
            var reservation1 = new Reservasion(goldCustomer1, DateTime.Now.AddHours(25));

            reservation1.Cancel();
            Console.WriteLine("Gold Customer, 25 Hrs before - Cancellation status: " + reservation1.IsCancelled);
            Console.WriteLine();

            reservation1 = new Reservasion(goldCustomer1, DateTime.Now.AddHours(23));
            reservation1.Cancel();
            Console.WriteLine("Gold Customer, less than 24 Hrs - Cancellation status: " + reservation1.IsCancelled);
            Console.WriteLine();

            reservation1 = new Reservasion(goldCustomer1, DateTime.Now.AddDays(-1));
            reservation1.Cancel();
            Console.WriteLine("Gold Customer, cancelling after start date - Cancellation status: " + reservation1.IsCancelled);
            Console.WriteLine();

            var regularCustomer1 = new CleanCodeExercises.NestedConditionalsRefactor.Customer()
            {
                LoyaltyPoints = 90
            };
            var reservation2 = new Reservasion(regularCustomer1, DateTime.Now.AddHours(49));

            reservation2.Cancel();
            Console.WriteLine("Regular Customer, 49 Hrs before - Cancellation status: " + reservation2.IsCancelled);
            Console.WriteLine();

            reservation2 = new Reservasion(regularCustomer1, DateTime.Now.AddHours(47));
            reservation2.Cancel();
            Console.WriteLine("Regular Customer, less than 48 Hrs - Cancellation status: " + reservation2.IsCancelled);
            Console.WriteLine();

            reservation2 = new Reservasion(regularCustomer1, DateTime.Now.AddDays(-1));
            reservation2.Cancel();
            Console.WriteLine("Regular Customer, cancelling after start date - Cancellation status: " + reservation2.IsCancelled);


            //Run DuplicateCodeRefactor Code
            //new DuplicateCode().AdmitGuest("John Smith", "17:10");
            //new DuplicateCode().UpdateAdmission(10, "Jane Parera", "12:27");

            //Run SwitchStatementRefactor Code
            //var customer1 = new PayAsYouGoCustomer();
            //var usage1 = new MonthlyUsage { CallMinutes = 130, SmsCount = 213, Customer = customer1 };
            //var statement1 = usage1.Customer.GenerateStatement(usage1);
            //statement1.PrintStatement();

            //var customer2 = new UnlimitedCustomer();
            //var usage2 = new MonthlyUsage { CallMinutes = 100, SmsCount = 100, Customer = customer2 };
            //var statement2 = usage2.Customer.GenerateStatement(usage2);
            //statement2.PrintStatement();
        }
Пример #3
0
        public async Task <IActionResult> Create([Bind("ReservasionId,GuestId,RoomId,AdultId,ChildId,RoomQuantityId,ArrivalTime,DepartureDate")] Reservasion reservasion)
        {
            if (ModelState.IsValid)
            {
                _context.Add(reservasion);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AdultId"]        = new SelectList(_context.Adult, "AdultId", "NumberOfAdults", reservasion.AdultId);
            ViewData["ChildId"]        = new SelectList(_context.Child, "ChildId", "NumberOfChild", reservasion.ChildId);
            ViewData["GuestId"]        = new SelectList(_context.Guest, "GuestId", "FullName", reservasion.GuestId);
            ViewData["RoomId"]         = new SelectList(_context.Room, "RoomId", "RoomTypeName", reservasion.RoomId);
            ViewData["RoomQuantityId"] = new SelectList(_context.RoomQuantity, "RoomQuantityId", "NumberOfRoom", reservasion.RoomQuantityId);
            return(View(reservasion));
        }
Пример #4
0
        public async Task <JsonResult> SaveReservasion(DateTime reservasionDate, DateTime reservasionTime, string name, string phone, string message)
        {
            Reservasion reservasion = new Reservasion();

            reservasion.Name    = name;
            reservasion.Date    = reservasionDate;
            reservasion.Phone   = phone;
            reservasion.Time    = reservasionTime;
            reservasion.Message = message;
            _context.Add(reservasion);
            int result = await _context.SaveChangesAsync();


            if (result == 1)
            {
                return(Json(true));
            }
            else
            {
                return(Json(false));
            }
        }