Ejemplo n.º 1
0
        public ActionResult Edit(ReservationViewModel reservation)
        {
            if (ModelState.IsValid)
            {
                var result = _unitOfWork.Reservation_List.UpdateWithRooms(ReservationMapper.Map(reservation), reservation.SelectedRooms);

                if (result)
                {
                    if (reservation.SelectedFellows != null)
                    {
                        _unitOfWork.Customer_List.UpdateFellows(reservation.ParentId, reservation.SelectedFellows);
                    }
                    Ok();
                    Reservation reservationSignalR = _unitOfWork.Reservation_List.Find(Guid.Parse(reservation.ID));
                    var         hub = new dashboardHub();
                    hub.Refresh(
                        reservationSignalR.ID.ToString(),
                        Translator.ReservationStateToPersian(reservationSignalR.Reservation_ReservationState.Title.ToString()),
                        reservationSignalR.Number.ToString(),
                        PersianDateConvertor.ConvertToPersianDate(reservationSignalR.FromDate, true),
                        PersianDateConvertor.ConvertToPersianDate(reservationSignalR.ToDate, true)
                        );
                    Response.Redirect("/Admin/Home/Index");
                    return(RedirectToAction("Index", "Reservation", null));
                }
            }
            Forbidden();
            return(Content(GenerateError()));
        }
Ejemplo n.º 2
0
        public DataSourceResult GetAllByDataSourceResultInDate(DataSourceRequest request, DateTime requestDate)
        {
            if (GetAll().Where(w => w.ReservationRooms_Reservation.FromDate <= requestDate && w.ReservationRooms_Reservation.ToDate >= requestDate).Count() != 0)
            {
                return(GetAll().Where(w => w.ReservationRooms_Reservation.FromDate <= requestDate && w.ReservationRooms_Reservation.ToDate >= requestDate).ToDataSourceResult(request, reservation => new
                {
                    ID = reservation.ID,
                    RequeestDate = PersianDateConvertor.ConvertToPersianDate(requestDate, true),
                    ReservationID = reservation.ReservationID,
                    RoomID = reservation.RoomID,
                    RoomNumber = reservation.ReservationRooms_Room.Number,
                    ReservationNumber = reservation.ReservationRooms_Reservation.Number,
                    ReservationType = Translator.ReservationStateToPersian(reservation.ReservationRooms_Reservation.Reservation_ReservationState.Title.ToString()),
                    DatePeriod = $"از تاریخ {PersianDateConvertor.ConvertToPersianDate(reservation.ReservationRooms_Reservation.FromDate, true)} تا {PersianDateConvertor.ConvertToPersianDate(reservation.ReservationRooms_Reservation.ToDate, true)}"
                }));
            }
            else
            {
                List <string> RequeestDate = new List <string>();
                RequeestDate.Add(PersianDateConvertor.ConvertToPersianDate(requestDate, true));

                DataSourceResult result = new DataSourceResult();
                result.Data = RequeestDate;

                return(result);
            }
        }
Ejemplo n.º 3
0
        public DataSourceResult GetFreeRooms(DataSourceRequest request, DateTime requestDate)
        {
            List <Room> freeRooms = new List <Room>();

            foreach (Room roomItem in GetAll())
            {
                bool AddOrNot = true;
                if (roomItem.Room_Checking_List != null)
                {
                    foreach (Checking checkingItem in roomItem.Room_Checking_List)
                    {
                        if ((requestDate > checkingItem.FromDate && requestDate > checkingItem.ToDate) || (requestDate < checkingItem.FromDate && requestDate < checkingItem.ToDate))
                        {
                            continue;
                        }
                        AddOrNot = false;
                    }
                }
                if (roomItem.Room_ReservationRooms_List != null)
                {
                    foreach (ReservationRooms reservationItem in roomItem.Room_ReservationRooms_List)
                    {
                        if ((requestDate > reservationItem.ReservationRooms_Reservation.FromDate && requestDate > reservationItem.ReservationRooms_Reservation.ToDate) || (requestDate < reservationItem.ReservationRooms_Reservation.FromDate && requestDate < reservationItem.ReservationRooms_Reservation.ToDate))
                        {
                            continue;
                        }
                        AddOrNot = false;
                    }
                }
                if (AddOrNot)
                {
                    freeRooms.Add(roomItem);
                }
            }


            if (freeRooms.Count != 0)
            {
                return(freeRooms.ToDataSourceResult(request, rooms => new
                {
                    ID = rooms.ID,
                    RequeestDate = PersianDateConvertor.ConvertToPersianDate(requestDate, true),
                    RoomNumber = rooms.Number
                }));
            }
            else
            {
                List <string> RequeestDate = new List <string>();
                RequeestDate.Add(PersianDateConvertor.ConvertToPersianDate(requestDate, true));
                DataSourceResult result = new DataSourceResult();
                result.Data = RequeestDate;
                return(result);
            }
        }
Ejemplo n.º 4
0
 public DataSourceResult GetAllByDataSourceResult(DataSourceRequest request)
 {
     return(GetAll().OrderByDescending(o => o.Number).ToDataSourceResult(request, reservation => new
     {
         ID = reservation.ID,
         State = Translator.ReservationStateToPersian(reservation.Reservation_ReservationState.Title.ToString()),
         CustomerID = reservation.CustomerID,
         CustomerFullName = reservation.Reservation_Customer.FullName,
         Number = reservation.Number,
         FromDate = $"{PersianDateConvertor.ConvertToPersianDate(reservation.FromDate, true)}",
         ToDate = $"{PersianDateConvertor.ConvertToPersianDate(reservation.ToDate, true)}",
         DatePeriod = $"از {PersianDateConvertor.ConvertToPersianDate(reservation.FromDate)} تا {PersianDateConvertor.ConvertToPersianDate(reservation.ToDate)}"
     }));
 }
Ejemplo n.º 5
0
        public DataSourceResult GetAllByDataSourceResult(DataSourceRequest request)
        {
            //Guid? reservationId = null;

            return(GetAll().OrderByDescending(d => d.CreateDate).ToDataSourceResult(request, checking => new
            {
                ID = checking.ID,
                RoomID = checking.Checking_Room.ID,
                RoomNumber = checking.Checking_Room.Number,
                FromDate = PersianDateConvertor.ConvertToPersianDate(checking.FromDate, true),
                ToDate = PersianDateConvertor.ConvertToPersianDate(checking.ToDate, true),
                ReservationID = checking.ReservationID,
                ReservationNumber = checking.Checking_Reservation == null ? "" : checking.Checking_Reservation.Number.ToString(),
            }));
        }
Ejemplo n.º 6
0
        public DataSourceResult GetAllForCustomerByDataSourceResult(DataSourceRequest request, string id)
        {
            Guid customerId = Guid.Parse(id);

            return(GetAll().Where(w => w.CustomerID == customerId).OrderByDescending(o => o.Number).ToDataSourceResult(request, reservation => new
            {
                ID = reservation.ID,
                State = reservation.Reservation_ReservationState.Title.ToString(),
                CustomerID = reservation.CustomerID,
                CustomerFullName = reservation.Reservation_Customer.FullName,
                Number = reservation.Number,
                FromDate = $"{PersianDateConvertor.ConvertToPersianDate(reservation.FromDate)}",
                ToDate = $"{PersianDateConvertor.ConvertToPersianDate(reservation.ToDate)}",
                DatePeriod = $"از {PersianDateConvertor.ConvertToPersianDate(reservation.FromDate)} تا {PersianDateConvertor.ConvertToPersianDate(reservation.ToDate)}"
            }));
        }
Ejemplo n.º 7
0
        public JsonResult Detail(string id)
        {
            InternshipHMSModels.Models.Checking checking = _unitOfWork.Checking_List.Find(Guid.Parse(id));

            return(Json(new
            {
                ID = checking.ID.ToString(),
                FromDate = PersianDateConvertor.ConvertToPersianDate(checking.FromDate, true),
                ToDate = PersianDateConvertor.ConvertToPersianDate(checking.ToDate, true),
                RoomID = checking.Checking_Room.ID.ToString(),
                RoomNumber = checking.Checking_Room.Number.ToString(),
                ReservationID = checking.Checking_Reservation == null ? "" : checking.Checking_Reservation.ID.ToString(),
                ReservationNumber = checking.Checking_Reservation == null ? "" : checking.Checking_Reservation.Number.ToString(),
                Passengers = _unitOfWork.Passenger_List.GetRoomPassengersByDataSourceResult(new DataSourceRequest()
                {
                    Page = 1, PageSize = 0
                }, checking.ID.ToString()),
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 8
0
 public JsonResult Detail(string id)
 {
     InternshipHMSModels.Models.Customer customer = _unitOfWork.Customer_List.Find(Guid.Parse(id));
     return(Json(new
     {
         ID = customer.ID,
         FirstName = customer.FirstName,
         LastName = customer.LastName,
         FullName = customer.FullName,
         NationalCode = customer.NationalCode,
         CustomerCode = customer.CustomerCode,
         PassportNumber = customer.PassportNumber,
         Birthdate = customer.Birthdate == null ? "" : $"{PersianDateConvertor.ConvertToPersianDate((DateTime)customer.Birthdate)} ({DateTime.Now.Year - customer.Birthdate.Value.Year})",
         Nationality = customer.Nationality,
         LivingPlace = customer.LivingPlace,
         ParentID = customer.ParentID == null ? "" : customer.ParentID.ToString(),
         ParentFullName = customer.ParentID == null ? "" : _unitOfWork.Customer_List.GetAll().FirstOrDefault(f => f.ID == customer.ParentID).FullName,
         Email = customer.Person_ApplicationUser == null ? "" : customer.Person_ApplicationUser.Email,
         LockoutEnabled = customer.Person_ApplicationUser == null ? "" : customer.Person_ApplicationUser.LockoutEnabled.ToString()
     }, JsonRequestBehavior.AllowGet));
 }
Ejemplo n.º 9
0
 public DataSourceResult GetAllByDataSourceResultInDate(DataSourceRequest request, DateTime requestDate)
 {
     if (GetAll().Where(w => w.FromDate <= requestDate && w.ToDate >= requestDate).Count() != 0)
     {
         return(GetAll().Where(w => w.FromDate <= requestDate && w.ToDate >= requestDate).ToDataSourceResult(request, checking => new
         {
             ID = checking.ID,
             RequeestDate = PersianDateConvertor.ConvertToPersianDate(requestDate, true),
             ReservationID = checking.ReservationID,
             RoomID = checking.RoomID,
             RoomNumber = checking.Checking_Room.Number,
             ReservationNumber = checking.Checking_Reservation == null ? "" : checking.Checking_Reservation.Number.ToString(),
             DatePeriod = $"از تاریخ {PersianDateConvertor.ConvertToPersianDate(checking.FromDate, true)} تا {PersianDateConvertor.ConvertToPersianDate(checking.ToDate, true)}"
         }));
     }
     else
     {
         List <string> RequeestDate = new List <string>();
         RequeestDate.Add(PersianDateConvertor.ConvertToPersianDate(requestDate, true));
         DataSourceResult result = new DataSourceResult();
         result.Data = RequeestDate;
         return(result);
     }
 }
Ejemplo n.º 10
0
        public JsonResult Detail(string id)
        {
            InternshipHMSModels.Models.Reservation reserve = _unitOfWork.Reservation_List.Find(Guid.Parse(id));

            return(Json(new
            {
                ID = reserve.ID.ToString(),
                Number = reserve.Number.ToString(),
                CustomerID = reserve.Reservation_Customer.ID.ToString(),
                CustomerFullName = reserve.Reservation_Customer.FullName.ToString(),
                State = Translator.ReservationStateToPersian(reserve.Reservation_ReservationState.Title.ToString()),
                StateID = reserve.Reservation_ReservationState.Title,
                FromDate = PersianDateConvertor.ConvertToPersianDate(reserve.FromDate, true),
                ToDate = PersianDateConvertor.ConvertToPersianDate(reserve.ToDate, true),
                Fellows = _unitOfWork.Customer_List.GetChildByDataSourceResult(new DataSourceRequest()
                {
                    Page = 1, PageSize = 0
                }, reserve.Reservation_Customer.ID.ToString()),
                Rooms = _unitOfWork.ReservationRooms_List.GetRoomsForReservationByDataSourceResult(new DataSourceRequest()
                {
                    Page = 1, PageSize = 0
                }, id)
            }, JsonRequestBehavior.AllowGet));
        }