public IEnumerable <AvailableRooms> AvailableRooms(BetweenDates dates)
        {
            var queryReservaton = db.Reservations.AsQueryable().Where(c => c.Status != 2);

            var queryRooms = db.Rooms.AsQueryable();

            var freeRooms = queryRooms
                            .Where(room => !queryReservaton
                                   .Where(res => (res.RoomID == room.ID) &&
                                          ((dates.DateIN >= res.DateIN && dates.DateIN < res.DateOUT) ||
                                           (dates.DateOUT > res.DateIN && dates.DateOUT < res.DateOUT))).Any());

            decimal countDays = (decimal)(dates.DateOUT - dates.DateIN).TotalDays;

            return(freeRooms
                   .Select(c => new AvailableRooms
            {
                ID = c.ID,
                Number = c.Number,
                Price = (c.RoomType.Price * countDays),
                Capacity = c.RoomType.Capacity,
                TypeName = c.RoomType.Name,
                Discription = c.RoomType.Discription
            }));
        }
        public IActionResult AvailableRooms(DateTime dateIN, DateTime dateOUT)
        {
            var betweenDates = new BetweenDates {
                DateIN = dateIN, DateOUT = dateOUT
            };

            var availableRooms = ReservationService.AvailableRooms(betweenDates).ToList();

            decimal countDays = (decimal)(dateOUT - dateIN).TotalDays;

            if (ReservationService.GetCountRooms() == availableRooms.Count)
            {
                var house = ReservationService.GetHouseInfo();

                availableRooms.Add(new AvailableRooms
                {
                    ID          = house.ID,
                    Number      = house.Number,
                    Price       = house.Price * countDays,
                    Discription = house.Discription,
                    TypeName    = house.TypeName,
                    Capacity    = house.Capacity
                });
            }

            return(View(new AvailableRoomsViewModel
            {
                AvailableRooms = availableRooms,
                DateIN = dateIN,
                DateOUT = dateOUT
            }));
        }
Exemple #3
0
        public ActionResult GetAllBetweenTwoDates([FromBody] BetweenDates dates)
        {
            var list = _repository.GetAllLogsBetweenTwoDates(dates);

            if (list.Count == 0)
            {
                return(NotFound());
            }

            return(Ok(list));
        }
        public IActionResult MadeReservations(ReservationsMadeViewModel model)
        {
            var dates = new BetweenDates
            {
                DateIN  = model.DateIN,
                DateOUT = model.DateOUT
            };

            var reservations = AdminService.GetReservationsMades(dates);

            return(View(new ReservationsMadeViewModel
            {
                DateIN = dates.DateIN,
                DateOUT = dates.DateOUT,
                ReservationsMades = reservations
            }));
        }
        public IActionResult MadeReservations(int id, int param)
        {
            if (param > 0)
            {
                AdminService.SetStatusToReservation(id, param);
            }
            var dates = new BetweenDates
            {
                DateIN  = DateTime.Today,
                DateOUT = DateTime.Today.AddDays(10)
            };

            var reservations = AdminService.GetReservationsMades(dates);

            return(View(new ReservationsMadeViewModel
            {
                DateIN = dates.DateIN,
                DateOUT = dates.DateOUT,
                ReservationsMades = reservations
            }));
        }
        public IEnumerable <ReservationsMade> GetReservationsMades(BetweenDates dates)
        {
            var QueryReservation = db.Reservations.AsQueryable();

            var Reservation = QueryReservation
                              .Where(res => (dates.DateIN >= res.DateIN && dates.DateIN <= res.DateOUT) ||
                                     (dates.DateOUT >= res.DateIN && dates.DateOUT <= res.DateOUT) ||
                                     (res.DateIN >= dates.DateIN && res.DateOUT <= dates.DateOUT));

            return(Reservation
                   .Select(c => new ReservationsMade
            {
                ReservationID = c.ID,
                DateIN = c.DateIN,
                DateOUT = c.DateOUT,
                RoomNomer = c.Room.Number,
                RoomType = c.Room.RoomType.Name,
                UserName = c.User.FName + " " + c.User.LName,
                PhoneNumber = c.User.PhoneNumber,
                Status = c.Status
            }));
        }
        public List <LogReadDto> GetAllLogsBetweenTwoDates(BetweenDates dates)
        {
            var list = _context.Logs.Where(e => e.CreatedAt >= dates.StartDate && e.CreatedAt <= dates.EndDate);

            return(_mapper.Map <List <LogReadDto> >(list));
        }
Exemple #8
0
        public MemoryStream WriteExcelStatementsBetweenDates(BetweenDates dates)
        {
            var memoryStream  = new MemoryStream();
            var allStatements = _context.AspStatement.Join(_context.AspCurrentStatus,
                                                           statement => statement.StatementId,
                                                           currentStatus => currentStatus.StatementId,
                                                           (statement, currentStatus) => new StatementWithAllStatuses
            {
                Statement     = statement,
                CurrentStatus = currentStatus
            }).Where(c => c.CurrentStatus.DateOfLastChanges >= dates.startDate && c.CurrentStatus.DateOfLastChanges <= dates.endDate).ToList();

            var statuses = _context.AspStatus.ToList();

            foreach (var statement in allStatements)
            {
                statement.CurrentStatus.Status = statuses.
                                                 FirstOrDefault(status => status.StatusId == statement.CurrentStatus.StatusId);
            }

            foreach (var item in allStatements)
            {
                item.Statement.UserLastNameGenitiveCase        = String.IsNullOrEmpty(item.Statement.UserLastNameGenitiveCase) ? "" : item.Statement.UserLastNameGenitiveCase;
                item.Statement.UserSurNameGenitiveCase         = String.IsNullOrEmpty(item.Statement.UserSurNameGenitiveCase) ? "" : item.Statement.UserSurNameGenitiveCase;
                item.Statement.UserNameGenitiveCase            = String.IsNullOrEmpty(item.Statement.UserNameGenitiveCase) ? "" : item.Statement.UserNameGenitiveCase;
                item.Statement.SubdivisionAtTheMainPlaceOfWork = String.IsNullOrEmpty(item.Statement.SubdivisionAtTheMainPlaceOfWork) ? "" : item.Statement.SubdivisionAtTheMainPlaceOfWork;
                item.Statement.PositionAtTheMainPlaceOfWork    = String.IsNullOrEmpty(item.Statement.PositionAtTheMainPlaceOfWork) ? "" : item.Statement.PositionAtTheMainPlaceOfWork;
                item.Statement.SubdivisionPartTime             = String.IsNullOrEmpty(item.Statement.SubdivisionPartTime) ? "" : item.Statement.SubdivisionPartTime;
                item.Statement.PositionPartTime              = String.IsNullOrEmpty(item.Statement.PositionPartTime) ? "" : item.Statement.PositionPartTime;
                item.Statement.TypeOfBusinessTrip            = String.IsNullOrEmpty(item.Statement.TypeOfBusinessTrip) ? "" : item.Statement.TypeOfBusinessTrip;
                item.Statement.PurposeOfBusinessTrip         = String.IsNullOrEmpty(item.Statement.PurposeOfBusinessTrip) ? "" : item.Statement.PurposeOfBusinessTrip;
                item.Statement.TypeOfSalaryRetention         = String.IsNullOrEmpty(item.Statement.TypeOfSalaryRetention) ? "" : item.Statement.TypeOfSalaryRetention;
                item.Statement.StatementPlaceOfDestination   = String.IsNullOrEmpty(item.Statement.StatementPlaceOfDestination) ? "" : item.Statement.StatementPlaceOfDestination;
                item.Statement.StatementCountryOfDestination = String.IsNullOrEmpty(item.Statement.StatementCountryOfDestination) ? "" : item.Statement.StatementCountryOfDestination;
                item.Statement.InstitutionWhereYouGo         = String.IsNullOrEmpty(item.Statement.InstitutionWhereYouGo) ? "" : item.Statement.InstitutionWhereYouGo;
                item.Statement.RouteOfBusinessTrip           = String.IsNullOrEmpty(item.Statement.RouteOfBusinessTrip) ? "" : item.Statement.RouteOfBusinessTrip;
                item.Statement.TransportOfBusinessTrip       = String.IsNullOrEmpty(item.Statement.TransportOfBusinessTrip) ? "" : item.Statement.TransportOfBusinessTrip;
                item.Statement.PaymentOfTravelExpenses       = String.IsNullOrEmpty(item.Statement.PaymentOfTravelExpenses) ? "" : item.Statement.PaymentOfTravelExpenses;
                item.Statement.BasisOfBusinessTrip           = String.IsNullOrEmpty(item.Statement.BasisOfBusinessTrip) ? "" : item.Statement.BasisOfBusinessTrip;
                item.CurrentStatus.Status.StatusName         = String.IsNullOrEmpty(item.CurrentStatus.Status.StatusName) ? "" : item.CurrentStatus.Status.StatusName;
            }

            var news_rows_isunder      = new List <string[]>();
            var header_news_rows_under = new List <object[]>()
            {
                new object[] { "Прізвище, ім'я, по-батькові (Р.В.)", "Підрозділ та посада за основним місцем праці",
                               "Відділ та посаду за сумісництвом (за наявності)", "Тип відрядження", "Мета відрядження", "Вид збереження заробітної плати",
                               "Місто відрядження", "Країна відрядження (для закордонного відрядження)", "Установа (куди відрядження)",
                               "Дата початку відрядження", "Дата завершення відрядження", "Маршрут поїздки (для відряджень по Україні)", "Транспорт (для відряджень по Україні)",
                               "Здійснення оплати видатків на відрядження", "Підстава відрядження", "Статус заяви", "Дата останньої зміни" }
            };

            using (ExcelPackage excel = new ExcelPackage())
            {
                excel.Workbook.Worksheets.Add("Поточні заяви");

                int    j            = 1;
                string header_under = "A" + j.ToString();
                j = j + header_news_rows_under.Count();

                string header_isunder = "A" + j.ToString();
                j = j + news_rows_isunder.Count();

                var worksheet = excel.Workbook.Worksheets["Поточні заяви"];
                worksheet.Cells[header_under].LoadFromArrays(header_news_rows_under);

                foreach (var item in allStatements)
                {
                    news_rows_isunder.Add(new string[] { item.Statement.UserSurNameGenitiveCase + " " + item.Statement.UserNameGenitiveCase + " " + item.Statement.UserLastNameGenitiveCase,
                                                         item.Statement.SubdivisionAtTheMainPlaceOfWork + " " + item.Statement.PositionAtTheMainPlaceOfWork, item.Statement.SubdivisionPartTime + " " + item.Statement.PositionPartTime,
                                                         item.Statement.TypeOfBusinessTrip, item.Statement.PurposeOfBusinessTrip, item.Statement.TypeOfSalaryRetention, item.Statement.StatementPlaceOfDestination,
                                                         item.Statement.StatementCountryOfDestination, item.Statement.InstitutionWhereYouGo, item.Statement.DateOfBusinessTrip.ToString(), item.Statement.DateOfСompletionBusinessTrip.ToString(),
                                                         item.Statement.RouteOfBusinessTrip, item.Statement.TransportOfBusinessTrip, item.Statement.PaymentOfTravelExpenses, item.Statement.BasisOfBusinessTrip,
                                                         item.CurrentStatus.Status.StatusName, item.CurrentStatus.DateOfLastChanges.ToString() });
                }

                worksheet.Cells[header_isunder].LoadFromArrays(news_rows_isunder);
                worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns();
                news_rows_isunder.Clear();
                memoryStream = new MemoryStream(excel.GetAsByteArray());
            }
            return(memoryStream);
        }
        public FileStreamResult ExcelStatementsBetweenDates(BetweenDates dates)
        {
            var memoryStream = _statementService.WriteExcelStatementsBetweenDates(dates);

            return(File(memoryStream, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Всі заяви.xlsx"));
        }
        public IActionResult StatementBetweenDates([Bind("startDate,endDate")] BetweenDates dates)
        {
            DateTime some = dates.startDate;

            return(View(dates));
        }