예제 #1
0
        public ActionResult BookRoom(CustomerBookingRoomModel model, string StartDate, string EndDate)
        {
            var customer = new Customer
            {
                Age = model.Age,
                FirstName = model.FirstName,
                LastName = model.LastName,
                DateCreated = DateTime.Now,
                DateUpdated = DateTime.Now,
                CreatedBy = string.Format("{0} {1}", model.FirstName, model.LastName),
                UpdatedBy = string.Format("{0} {1}", model.FirstName, model.LastName),
                Gender = model.Gender
            };
            ContactInformation contact = null;
            if (!string.IsNullOrWhiteSpace(model.AddressContact) || !string.IsNullOrWhiteSpace(model.CityContact)
                || !string.IsNullOrWhiteSpace(model.EmailContact) || !string.IsNullOrWhiteSpace(model.FaxNumberContact)
                || !string.IsNullOrWhiteSpace(model.FirstNameContact) || !string.IsNullOrWhiteSpace(model.LastNameContact)
                || !string.IsNullOrWhiteSpace(model.PhoneContact))
            {
                contact = new ContactInformation
                {
                    Address = model.AddressContact,
                    City = model.CityContact,
                    Email = model.EmailContact,
                    FaxNumber = model.FaxNumberContact,
                    FirstName = model.FirstNameContact,
                    LastName = model.LastNameContact,
                    PhoneNumber = model.PhoneContact,
                    DateCreated = DateTime.Now,
                    DateUpdated = DateTime.Now,
                    CreatedBy = string.Format("{0} {1}", model.FirstName, model.LastName),
                    UpdatedBy = string.Format("{0} {1}", model.FirstName, model.LastName),
                    ContactTypeId = 5,
                };
            }

            model.StartDate = DateTime.ParseExact(StartDate, "dd-MM-yyyy", CultureInfo.InvariantCulture);
            model.EndDate = DateTime.ParseExact(EndDate, "dd-MM-yyyy", CultureInfo.InvariantCulture);

            BookRoomService.BookRoom(customer, contact
                , model.RoomId, model.StartDate, model.EndDate, model.Service, model.Equipment);
            return Json(new { success = true }, JsonRequestBehavior.AllowGet);
        }
예제 #2
0
파일: Employee.cs 프로젝트: malt2586/repos
        //CONSTRUCTORS
        public Employee(string firstname, string lastname, string titleOfCourtesy, string title, string position, bool isHourlyPaid, int employeeId, DateTime hireDate, char sex)
        {
            try
            {
                contact = new ContactInformation(firstname, lastname, titleOfCourtesy, title, position);

                //Firstname = firstname;
                //Lastname = lastname;
                //TitleOfCourtesy = titleOfCourtesy;
                //Title = title;
                //Position = position;

                IsHourlyPaid = isHourlyPaid;
                EmployeeId   = employeeId;
                HireDate     = hireDate;
                Sex          = sex;
            }
            catch (ArgumentException) { throw; }
        }
예제 #3
0
        public static void BookRoom(Customer customer, ContactInformation contact, int roomId, DateTime startDate, DateTime endDate, int[] service, int[] equipment)
        {
            using (var context = new MimosaEntities())
            {
                decimal totalPrice = 0;
                var room = context.Rooms.FirstOrDefault(x => x.RoomId == roomId);

                if (contact != null)
                {
                    context.ContactInformations.Add(contact);
                    context.SaveChanges();
                }

                if (room != null)
                {
                    var bookRoom = new Booking
                    {
                        DateCreated = DateTime.Now,
                        DateUpdated = DateTime.Now,
                        CreatedBy = string.Format("{0} {1}", customer.FirstName, customer.LastName),
                        UpdatedBy = string.Format("{0} {1}", customer.FirstName, customer.LastName),
                        RoomId = roomId,
                        BookDate = DateTime.Now,
                        CustomerId = customer.CustomerId,
                        BookingStatusId = 1,
                        RoomPrice = room.BasePrice,
                        Description = "",
                        ContractDateStart = startDate,
                        ContractDateEnd = endDate
                    };

                    if (service != null)
                    {
                        foreach (var id in service)
                        {
                            var itemService = context.RoomServices.FirstOrDefault(x => x.ServiceId == id);
                            if (itemService != null)
                            {
                                totalPrice += itemService.Price ?? 0;
                                bookRoom.BookingRoomServices.Add(
                                    new BookingRoomService
                                {
                                    RoomServiceId = itemService.RoomServiceId,
                                    DateCreated = DateTime.Now,
                                    DateUpdated = DateTime.Now,
                                    Price = itemService.Price,
                                    CreatedBy = string.Format("{0} {1}", customer.FirstName, customer.LastName),
                                    UpdatedBy = string.Format("{0} {1}", customer.FirstName, customer.LastName)
                                });
                            }
                        }
                    }

                    if (equipment != null)
                    {
                        foreach (var id in equipment)
                        {
                            var itemEquipment = context.RoomEquipments.FirstOrDefault(x => x.EquipmentId == id);
                            if (itemEquipment != null)
                            {
                                totalPrice += itemEquipment.Price ?? 0;
                                bookRoom.BookingRoomEquipments.Add(
                                    new BookingRoomEquipment
                                    {
                                        RoomEquipmentId = itemEquipment.RoomEquipmentId,
                                        DateCreated = DateTime.Now,
                                        DateUpdated = DateTime.Now,
                                        Price = itemEquipment.Price,
                                        CreatedBy = string.Format("{0} {1}", customer.FirstName, customer.LastName),
                                        UpdatedBy = string.Format("{0} {1}", customer.FirstName, customer.LastName)
                                    });
                            }
                        }
                    }

                    if (contact != null)
                    {
                        customer.ContactInformationId = contact.ContactInformationId;
                    }
                    customer.OrganisationID = room.Site.OrganisationID;
                    bookRoom.TotalPrice = totalPrice;
                    customer.Bookings.Add(bookRoom);

                    context.Customers.Add(customer);
                    context.SaveChanges();
                }
            }
        }