Exemple #1
0
        Create([Bind("HotelID,Name")] Branch branch)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    branch.BranchID = Guid.NewGuid();
                    _context.Add(branch);

                    BranchVardata branchvardata = new BranchVardata {
                        Branch = branch
                    };
                    _context.Add(branchvardata);

                    Nationality usualnationality = await _context.Nationalities.FirstOrDefaultAsync();

                    BranchVardataReservation branchvardatareservation = new BranchVardataReservation {
                        Branch = branch, UsualNationality = usualnationality
                    };
                    _context.Add(branchvardatareservation);

                    await _context.SaveChangesAsync();

                    return(RedirectToAction("Edit", new { id = branch.BranchID }));
                }
            }
            catch (DbUpdateException)
            {
                ModelState.AddModelError("", "Unable to save changes. " +
                                         "Try again, and if the problem persists " +
                                         "see your system administrator.");
            }
            ViewData["HotelID"] = new SelectList(_context.Hotels, "HotelID", "Name", branch.HotelID);
            return(View(branch));
        }
        public async Task <IActionResult> Create([Bind("Name")] HotelGroup hotelGroup)
        {
            if (ModelState.IsValid)
            {
                hotelGroup.HotelGroupID = Guid.NewGuid();
                _context.Add(hotelGroup);

                Hotel hotel = new Hotel
                {
                    HotelGroup     = hotelGroup,
                    HotelID        = Guid.NewGuid(),
                    ExpirationDate = DateTime.Today.AddMonths(6),
                    Name           = hotelGroup.Name,
                    HotelDate      = DateTime.Today
                };

                _context.Add(hotel);

                //----------------------------------------------------------------
                Department Room = new Department {
                    DepartmentID = Guid.NewGuid(), Hotel = hotel, Name = "Δωμάτια", IsActive = true, TaxPrcentage = 0.005M, VatPercentage = 0.13M, DisplayOrder = 1
                };
                Department Breakfast = new Department {
                    DepartmentID = Guid.NewGuid(), Hotel = hotel, Name = "Πρωϊνό", IsActive = true, TaxPrcentage = 0.005M, VatPercentage = 0.24M, DisplayOrder = 2
                };
                Department Lunch = new Department {
                    DepartmentID = Guid.NewGuid(), Hotel = hotel, Name = "Γεύμα", IsActive = true, TaxPrcentage = 0.005M, VatPercentage = 0.24M, DisplayOrder = 3
                };
                Department Dinner = new Department {
                    DepartmentID = Guid.NewGuid(), Hotel = hotel, Name = "Δείπνο", IsActive = true, TaxPrcentage = 0.005M, VatPercentage = 0.24M, DisplayOrder = 4
                };
                Department AllInclusive = new Department {
                    DepartmentID = Guid.NewGuid(), Hotel = hotel, Name = "All Inclusive", IsActive = true, TaxPrcentage = 0.005M, VatPercentage = 0.24M, DisplayOrder = 5
                };

                _context.AddRange(new[] { Room, Breakfast, Lunch, Dinner, AllInclusive });

                Board RR = new Board {
                    BoardID = Guid.NewGuid(), Hotel = hotel, Abbrevation = "RR", Name = "Room Rate", DisplayOrder = 1
                };
                Board BB = new Board {
                    BoardID = Guid.NewGuid(), Hotel = hotel, Abbrevation = "BB", Name = "Bed n' breakfast", DisplayOrder = 2
                };
                Board HL = new Board {
                    BoardID = Guid.NewGuid(), Hotel = hotel, Abbrevation = "HL", Name = "Half Lunch", DisplayOrder = 3
                };
                Board HB = new Board {
                    BoardID = Guid.NewGuid(), Hotel = hotel, Abbrevation = "HB", Name = "Half Board", DisplayOrder = 4
                };
                Board FB = new Board {
                    BoardID = Guid.NewGuid(), Hotel = hotel, Abbrevation = "FB", Name = "Full Board", DisplayOrder = 5
                };
                Board AI = new Board {
                    BoardID = Guid.NewGuid(), Hotel = hotel, Abbrevation = "AL", Name = "All Inclusive", DisplayOrder = 6
                };

                _context.AddRange(new[] { RR, BB, HL, HB, FB, AI });

                BoardPart RR_Room = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = RR, Department = Room, ParticipationRate = 1
                };

                BoardPart BB_Room = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = BB, Department = Room, ParticipationRate = 0.95d
                };
                BoardPart BB_Breakfast = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = BB, Department = Breakfast, ParticipationRate = 0.05d
                };

                BoardPart HL_Room = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = HL, Department = Room, ParticipationRate = 0.85d
                };
                BoardPart HL_Breakfast = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = HL, Department = Breakfast, ParticipationRate = 0.05d
                };
                BoardPart HL_Lunch = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = HL, Department = Lunch, ParticipationRate = 0.1d
                };

                BoardPart HB_Room = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = HB, Department = Room, ParticipationRate = 0.85d
                };
                BoardPart HB_Breakfast = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = HB, Department = Breakfast, ParticipationRate = 0.05d
                };
                BoardPart HB_Dinner = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = HB, Department = Dinner, ParticipationRate = 0.1d
                };

                BoardPart FB_Room = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = FB, Department = Room, ParticipationRate = 0.75d
                };
                BoardPart FB_Breakfast = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = FB, Department = Breakfast, ParticipationRate = 0.05d
                };
                BoardPart FB_Lunch = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = FB, Department = Lunch, ParticipationRate = 0.1d
                };
                BoardPart FB_Dinner = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = FB, Department = Dinner, ParticipationRate = 0.1d
                };

                BoardPart AI_Room = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = AI, Department = Room, ParticipationRate = 0.7d
                };
                BoardPart AI_Breakfast = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = AI, Department = Breakfast, ParticipationRate = 0.05d
                };
                BoardPart AI_Lunch = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = AI, Department = Lunch, ParticipationRate = 0.1d
                };
                BoardPart AI_Dinner = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = AI, Department = Dinner, ParticipationRate = 0.1d
                };
                BoardPart AI_AI = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = AI, Department = AllInclusive, ParticipationRate = 0.05d
                };

                _context.AddRange(new[] { RR_Room,
                                          BB_Room, BB_Breakfast,
                                          HL_Room, HL_Breakfast, HL_Lunch,
                                          HB_Room, HB_Breakfast, HB_Dinner,
                                          FB_Room, FB_Breakfast, FB_Lunch, FB_Dinner,
                                          AI_Room, AI_Breakfast, AI_Lunch, AI_Dinner, AI_AI });
                //----------------------------------------------------------------

                HotelVardataPlan hotelvardataplan = new HotelVardataPlan {
                    Hotel = hotel
                };
                _context.Add(hotelvardataplan);

                HotelVardataInvoice hotelvardatainvoice = new HotelVardataInvoice {
                    Hotel = hotel
                };
                _context.Add(hotelvardatainvoice);

                Branch branch = new Branch {
                    Hotel = hotel, Name = hotel.Name
                };
                _context.Add(branch);

                BranchVardata branchvardata = new BranchVardata {
                    Branch = branch
                };
                _context.Add(branchvardata);

                Nationality usualnationality = await _context.Nationalities.FirstOrDefaultAsync();

                BranchVardataReservation branchvardatareservation = new BranchVardataReservation {
                    Branch = branch, UsualNationality = usualnationality
                };
                _context.Add(branchvardatareservation);

                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(hotelGroup));
        }
Exemple #3
0
        Create([Bind("Dealer,ExpirationDate,HotelDate,HotelGroupID,IsPayingSupport,Name")] Hotel hotel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    hotel.HotelID = Guid.NewGuid();
                    _context.Add(hotel);

                    Department Room = new Department {
                        DepartmentID = Guid.NewGuid(), Hotel = hotel, Name = "Δωμάτια", IsActive = true, TaxPrcentage = 0.005M, VatPercentage = 0.13M, DisplayOrder = 1
                    };
                    Department Breakfast = new Department {
                        DepartmentID = Guid.NewGuid(), Hotel = hotel, Name = "Πρωϊνό", IsActive = true, TaxPrcentage = 0.005M, VatPercentage = 0.24M, DisplayOrder = 2
                    };
                    Department Lunch = new Department {
                        DepartmentID = Guid.NewGuid(), Hotel = hotel, Name = "Γεύμα", IsActive = true, TaxPrcentage = 0.005M, VatPercentage = 0.24M, DisplayOrder = 3
                    };
                    Department Dinner = new Department {
                        DepartmentID = Guid.NewGuid(), Hotel = hotel, Name = "Δείπνο", IsActive = true, TaxPrcentage = 0.005M, VatPercentage = 0.24M, DisplayOrder = 4
                    };
                    Department AllInclusive = new Department {
                        DepartmentID = Guid.NewGuid(), Hotel = hotel, Name = "All Inclusive", IsActive = true, TaxPrcentage = 0.005M, VatPercentage = 0.24M, DisplayOrder = 5
                    };

                    _context.AddRange(new[] { Room, Breakfast, Lunch, Dinner, AllInclusive });

                    Board RR = new Board {
                        BoardID = Guid.NewGuid(), Hotel = hotel, Abbrevation = "RR", Name = "Room Rate", DisplayOrder = 1
                    };
                    Board BB = new Board {
                        BoardID = Guid.NewGuid(), Hotel = hotel, Abbrevation = "BB", Name = "Bed n' breakfast", DisplayOrder = 2
                    };
                    Board HL = new Board {
                        BoardID = Guid.NewGuid(), Hotel = hotel, Abbrevation = "HL", Name = "Half Lunch", DisplayOrder = 3
                    };
                    Board HB = new Board {
                        BoardID = Guid.NewGuid(), Hotel = hotel, Abbrevation = "HB", Name = "Half Board", DisplayOrder = 4
                    };
                    Board FB = new Board {
                        BoardID = Guid.NewGuid(), Hotel = hotel, Abbrevation = "FB", Name = "Full Board", DisplayOrder = 5
                    };
                    Board AI = new Board {
                        BoardID = Guid.NewGuid(), Hotel = hotel, Abbrevation = "AL", Name = "All Inclusive", DisplayOrder = 6
                    };

                    _context.AddRange(new[] { RR, BB, HL, HB, FB, AI });

                    BoardPart RR_Room = new BoardPart {
                        BoardPartID = Guid.NewGuid(), Board = RR, Department = Room, ParticipationRate = 1
                    };

                    BoardPart BB_Room = new BoardPart {
                        BoardPartID = Guid.NewGuid(), Board = BB, Department = Room, ParticipationRate = 0.95d
                    };
                    BoardPart BB_Breakfast = new BoardPart {
                        BoardPartID = Guid.NewGuid(), Board = BB, Department = Breakfast, ParticipationRate = 0.05d
                    };

                    BoardPart HL_Room = new BoardPart {
                        BoardPartID = Guid.NewGuid(), Board = HL, Department = Room, ParticipationRate = 0.85d
                    };
                    BoardPart HL_Breakfast = new BoardPart {
                        BoardPartID = Guid.NewGuid(), Board = HL, Department = Breakfast, ParticipationRate = 0.05d
                    };
                    BoardPart HL_Lunch = new BoardPart {
                        BoardPartID = Guid.NewGuid(), Board = HL, Department = Lunch, ParticipationRate = 0.1d
                    };

                    BoardPart HB_Room = new BoardPart {
                        BoardPartID = Guid.NewGuid(), Board = HB, Department = Room, ParticipationRate = 0.85d
                    };
                    BoardPart HB_Breakfast = new BoardPart {
                        BoardPartID = Guid.NewGuid(), Board = HB, Department = Breakfast, ParticipationRate = 0.05d
                    };
                    BoardPart HB_Dinner = new BoardPart {
                        BoardPartID = Guid.NewGuid(), Board = HB, Department = Dinner, ParticipationRate = 0.1d
                    };

                    BoardPart FB_Room = new BoardPart {
                        BoardPartID = Guid.NewGuid(), Board = FB, Department = Room, ParticipationRate = 0.75d
                    };
                    BoardPart FB_Breakfast = new BoardPart {
                        BoardPartID = Guid.NewGuid(), Board = FB, Department = Breakfast, ParticipationRate = 0.05d
                    };
                    BoardPart FB_Lunch = new BoardPart {
                        BoardPartID = Guid.NewGuid(), Board = FB, Department = Lunch, ParticipationRate = 0.1d
                    };
                    BoardPart FB_Dinner = new BoardPart {
                        BoardPartID = Guid.NewGuid(), Board = FB, Department = Dinner, ParticipationRate = 0.1d
                    };

                    BoardPart AI_Room = new BoardPart {
                        BoardPartID = Guid.NewGuid(), Board = AI, Department = Room, ParticipationRate = 0.7d
                    };
                    BoardPart AI_Breakfast = new BoardPart {
                        BoardPartID = Guid.NewGuid(), Board = AI, Department = Breakfast, ParticipationRate = 0.05d
                    };
                    BoardPart AI_Lunch = new BoardPart {
                        BoardPartID = Guid.NewGuid(), Board = AI, Department = Lunch, ParticipationRate = 0.1d
                    };
                    BoardPart AI_Dinner = new BoardPart {
                        BoardPartID = Guid.NewGuid(), Board = AI, Department = Dinner, ParticipationRate = 0.1d
                    };
                    BoardPart AI_AI = new BoardPart {
                        BoardPartID = Guid.NewGuid(), Board = AI, Department = AllInclusive, ParticipationRate = 0.05d
                    };

                    _context.AddRange(new[] { RR_Room,
                                              BB_Room, BB_Breakfast,
                                              HL_Room, HL_Breakfast, HL_Lunch,
                                              HB_Room, HB_Breakfast, HB_Dinner,
                                              FB_Room, FB_Breakfast, FB_Lunch, FB_Dinner,
                                              AI_Room, AI_Breakfast, AI_Lunch, AI_Dinner, AI_AI });

                    HotelVardataPlan hotelvardataplan = new HotelVardataPlan {
                        Hotel = hotel
                    };
                    _context.Add(hotelvardataplan);

                    HotelVardataInvoice hotelvardatainvoice = new HotelVardataInvoice {
                        Hotel = hotel
                    };
                    _context.Add(hotelvardatainvoice);

                    Branch branch = new Branch {
                        Hotel = hotel, Name = hotel.Name
                    };
                    _context.Add(branch);

                    BranchVardata branchvardata = new BranchVardata {
                        Branch = branch
                    };
                    _context.Add(branchvardata);

                    Nationality usualnationality = await _context.Nationalities.FirstOrDefaultAsync();

                    BranchVardataReservation branchvardatareservation = new BranchVardataReservation {
                        Branch = branch, UsualNationality = usualnationality
                    };
                    _context.Add(branchvardatareservation);

                    await _context.SaveChangesAsync();

                    return(RedirectToAction("Edit", new { id = hotel.HotelID }));
                }
            }
            catch (DbUpdateException ex)
            {
                ModelState.AddModelError("", "Unable to save changes. " +
                                         "Try again, and if the problem persists " +
                                         "see your system administrator.");
            }
            ViewData["HotelGroupID"] = new SelectList(_context.HotelGroups, "HotelGroupID", "Name", hotel.HotelGroupID);
            return(View(hotel));
        }