Ejemplo n.º 1
0
 public static Language Get(int id)
 {
     using (var context = new MimosaEntities())
     {
         return context.Languages.First(x => x.Id == id);
     }
 }
Ejemplo n.º 2
0
 public static List<Language> GetListAll()
 {
     using (var context = new MimosaEntities())
     {
         return context.Languages.OrderBy(x => x.Id).ToList();
     }
 }
 public static List<LocaleStringResource> GetListAll()
 {
     using (var context = new MimosaEntities())
     {
         return context.LocaleStringResources.OrderBy(x => x.ResourceName).ToList();
     }
 }
Ejemplo n.º 4
0
 public static List<District> GetDistricts()
 {
     using (var context = new MimosaEntities())
     {
         return context.Districts.AsNoTracking().OrderBy(x => x.DistrictCode).ToList();
     }
 }
Ejemplo n.º 5
0
 public static List<RoomType> GetRoomTypeList()
 {
     using (var context = new MimosaEntities())
     {
         return context.RoomTypes.AsNoTracking().ToList();
     }
 }
 public static LocaleStringResource Get(int id)
 {
     using (var context = new MimosaEntities())
     {
         return context.LocaleStringResources.Include(x => x.Language).First(x => x.Id == id);
     }
 }
Ejemplo n.º 7
0
 public static List<Image> GetListImageRoom(int[] roomIdList)
 {
     using (var context = new MimosaEntities())
     {
         return context.Images.Where(x => roomIdList.Contains(x.ItemId)).AsNoTracking().ToList();
     }
 }
Ejemplo n.º 8
0
        public static List<Image> GetListImageRoomDetails(int roomId)
        {
            using (var context = new MimosaEntities())
            {
                var serviceRoomId =
                    context.RoomServices.Where(x => x.RoomId == roomId)
                        .AsNoTracking()
                        .Select(x => x.ServiceId)
                        .ToArray();

                var equipmentRoomId =
                    context.RoomEquipments.Where(x => x.RoomId == roomId)
                        .AsNoTracking()
                        .Select(x => x.EquipmentId)
                        .ToArray();

                var query = context.Images.Where(x => x.ItemId == roomId && x.ImageTypeId == 3);
                query = query.Union(context.Images.Where(x => serviceRoomId.Contains(x.ItemId) && x.ImageTypeId == 5));
                query = query.Union(context.Images.Where(x => equipmentRoomId.Contains(x.ItemId) && x.ImageTypeId == 4));

                return query.AsNoTracking().ToList();
            }
        }
Ejemplo n.º 9
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();
                }
            }
        }
Ejemplo n.º 10
0
        public static Tuple<int?, int?, int?> GetStatistic()
        {
            int? count1 = 0;
            int? count2 = 0;
            int? count3 = 0;
            using (var context = new MimosaEntities())
            {
                var item = context.VisitorOfDays.FirstOrDefault(
                    x => x.Day == DateTime.Now.Day && x.Month == DateTime.Now.Month && x.Year == DateTime.Now.Year);
                if (item != null)
                {
                    count1 = item.Count;
                }

                var firstDayOfWeek = FirstDayOfWeekUtility.GetFirstDayOfWeek(DateTime.Now);
                var lastDayOfWeek = firstDayOfWeek.AddDays(7);

                count2 =
                    context.VisitorOfDays.Where(
                        x => x.DateTime >= firstDayOfWeek && x.DateTime <= lastDayOfWeek).Sum(x => x.Count);

                var day = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month);
                var lastDateMonth = new DateTime(DateTime.Now.Year, DateTime.Now.Month, day);
                var firstDateMonth = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);

                count3 =
                    context.VisitorOfDays.Where(
                        x => x.DateTime >= firstDateMonth && x.DateTime <= lastDateMonth).Sum(x => x.Count);

            }
            return new Tuple<int?, int?, int?>(count1, count2, count3);
        }
Ejemplo n.º 11
0
 public static Room RoomDetails(int roomId)
 {
     using (var context = new MimosaEntities())
     {
         return
             context.Rooms.Include(x => x.RoomServices.Select(c => c.Service))
                 .Include(x => x.RoomEquipments.Select(c => c.Equipment))
                 .Include(x => x.RoomStatus)
                 .Include(x => x.Site.ContactInformation)
                 .AsNoTracking()
                 .FirstOrDefault(x => x.RoomId == roomId);
     }
 }
Ejemplo n.º 12
0
        public static List<Room> ListRoom(int? area, int? money, int? roomType, string district, int pageIndex, int pageSize,
            out int totalRecords)
        {
            using (var context = new MimosaEntities())
            {
                IQueryable<Room> query = context.Rooms;
                if (area.HasValue)
                {
                    if (area == (int)Area.Less10MeterSquare)
                    {
                        query = query.Where(x => x.MeterSquare < 10);
                    }
                    else if (area == (int)Area.MeterSquar10And20)
                    {
                        query = query.Where(x => x.MeterSquare >= 10 && x.MeterSquare <= 20);
                    }
                    else if (area == (int)Area.MeterSquar20And30)
                    {
                        query = query.Where(x => x.MeterSquare >= 20 && x.MeterSquare <= 30);
                    }
                    else if (area == (int)Area.Than30MeterSquare)
                    {
                        query = query.Where(x => x.MeterSquare >= 30);
                    }
                }

                if (money.HasValue)
                {
                    if (money == (int)Money.Less3Million)
                    {
                        query = query.Where(x => x.BasePrice < 3000000);
                    }
                    else if (money == (int)Money.Million3And5)
                    {
                        query = query.Where(x => x.BasePrice >= 3000000 && x.BasePrice <= 5000000);
                    }
                    else if (money == (int)Money.Than5Million)
                    {
                        query = query.Where(x => x.BasePrice > 5000000);
                    }
                }

                if(!string.IsNullOrWhiteSpace(district))
                {
                    query = query.Where(x => x.Site.ContactInformation.District.Equals(district));
                }

                if (roomType.HasValue)
                {
                    query = query.Where(x => x.RoomTypeId == roomType.Value);
                }

                totalRecords = query.Count();
                return query.OrderByDescending(x => x.RoomId).Skip(pageSize * (pageIndex - 1)).Take(pageSize).Include(x => x.RoomStatus).AsNoTracking().ToList();
            }
        }
Ejemplo n.º 13
0
 public static void InsertCustomer()
 {
     var date = DateTime.Now;
     using (var context = new MimosaEntities())
     {
         var item =
             context.VisitorOfDays.FirstOrDefault(
                 x => x.Day == date.Day && x.Month == date.Month && x.Year == date.Year);
         if (item == null)
         {
             context.VisitorOfDays.Add(new VisitorOfDay { Count = 1, DateTime = date, Day = date.Day, Month = date.Month, Year = date.Year });
         }
         else
         {
             item.Count++;
         }
         context.SaveChanges();
     }
 }