Пример #1
0
        // GET: Accomodations/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Accomodation accomodation = db.Accomodations.Find(id);

            if (accomodation == null)
            {
                return(HttpNotFound());
            }
            AccomodationViewModel vm = new AccomodationViewModel();

            vm.Id              = accomodation.Id;
            vm.UserId          = accomodation.UserId;
            vm.Posted_Date     = accomodation.Posted_Date;
            vm.Number_of_Rooms = accomodation.Number_of_Rooms;
            vm.Rent            = accomodation.Rent;
            vm.PetFriendly     = accomodation.PetFriendly;
            vm.Parking         = accomodation.Parking;
            vm.Floor           = accomodation.Floor;
            vm.Furnished       = accomodation.Furnished;
            vm.Location        = accomodation.Location;
            vm.Description     = accomodation.Description;
            vm.Images          = accomodation.AccomodationImages.Where(t => t.AccomodationId == accomodation.Id).ToList();
            return(View(vm));
        }
Пример #2
0
        public IHttpActionResult PutAccomodation(int id, AccomodationViewModel accomodationViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != accomodationViewModel.AccomodationId)
            {
                return(BadRequest());
            }

            Accomodation accomodation = ViewModelMapper.ToModelAccomodations(accomodationViewModel);

            db.Entry(accomodation).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AccomodationExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public AccomodationViewModel Add(Guid environmentId, AccomodationViewModel accomodationViewModel)
        {
            accomodationViewModel.EnviromentId = environmentId;
            var accomodation = _mapper.Map <Accomodation>(accomodationViewModel);

            return(_mapper.Map <AccomodationViewModel>(_accomodationService.Add(accomodation)));
        }
Пример #4
0
        public IHttpActionResult PostAccomodation(AccomodationViewModel accomodationViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Client c = db.Clients.SingleOrDefault(x => x.FirstName + " " + x.LastName == accomodationViewModel.ClientName);

            if (c == null)
            {
                string[] parts     = accomodationViewModel.ClientName.Split(' ');
                Client   newClient = new Client()
                {
                    FirstName = parts.FirstOrDefault(), LastName = parts.LastOrDefault()
                };
                c = db.Clients.Add(newClient);
            }

            Accomodation accomodation = ViewModelMapper.ToModelAccomodations(accomodationViewModel);

            accomodation.Client = c;
            db.Accomodations.Add(accomodation);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = accomodation.AccomodationId }, ViewModelMapper.ToViewModelAccomodations(accomodation)));
        }
Пример #5
0
        public ActionResult Index(int accomodationTypeId, int?accomodationPackageId)
        {
            AccomodationViewModel model = new AccomodationViewModel();

            model.AccomodationTypes             = accomodationTypeService.GetAccomodationTypeId(accomodationTypeId);
            model.AccomodationPackages          = accomodationPackageService.GetAllAccomodationPackageByAccomodationType(accomodationTypeId);
            model.selectedAccomodationPackageId = accomodationPackageId.HasValue ? accomodationPackageId.Value : model.AccomodationPackages.First().Id;
            model.Accomodations = accomodationService.GetAllAccomodationByAccomodationPackage(model.selectedAccomodationPackageId);
            return(View(model));
        }
        // GET: Accomodations
        public ActionResult Index(int accomodationTypeID, int?accomodationPackageID)
        {
            AccomodationViewModel models = new AccomodationViewModel();

            models.AccomodationType              = accomodationTypesService.GetAccomodationTypeByID(accomodationTypeID);
            models.AccomodationPackages          = accomodationPackagesService.GetAllAccomodationPackagesByAccomodationType(accomodationTypeID);
            models.SelectedAccomodationPackageID = accomodationPackageID.HasValue ? accomodationPackageID.Value : models.AccomodationPackages.First().ID;
            models.Accomodations = accomodationsService.GetAllAccomodationsByAccomodationPackage(models.SelectedAccomodationPackageID);
            return(View(models));
        }
        public async Task <IActionResult> DetailsReservation(Guid accomodationId)
        {
            if (accomodationId == Guid.Empty)
            {
                return(Json(Conflict()));
            }

            AccomodationViewModel accomodationVM = _accomodationAppService.GetAccomodationAndCulturalExchangeList(accomodationId);

            return(View(accomodationVM));
        }
        public async Task <IActionResult> Edit(AccomodationViewModel accomodationViewModel)
        {
            if (ModelState.IsValid)
            {
                _accomodationAppService.Update(accomodationViewModel);

                return(RedirectToAction("Index", "Accomodation"));
            }

            return(View(accomodationViewModel));
        }
Пример #9
0
        public JsonResult Accomodation(AccomodationViewModel model)
        {
            positionSetReq = new PositionSetReq();
            

            if (model.SaveType == "partial")
            {
                model.AccomodationData.RemoveAll(x => (x.AccomodationSequence == 0));
            }
            else if (model.SaveType == "full")
            {
                model.AccomodationData.RemoveAll(x => (x.AccomodationSequence == 0 && string.IsNullOrEmpty(x.AccomodationId)));
            }
            bool IsValid = accomoMapping.ValidateAccomodationWithRouting(model, token);
            if (IsValid)
            {
                positionSetReq = accomoMapping.AccomodationSet(model, ckUserEmailId,token);
                positionSetReq.FOC = model.FOC;
                positionSetReq.Price = model.Price;
                positionSetReq.QRFID = model.MenuViewModel.QRFID;
                positionSetReq.VoyagerUserID = ckLoginUser_Id;
                positionSetRes = positionProviders.SetPosition(positionSetReq, token).Result;
                if (positionSetRes.ResponseStatus.Status.ToLower() == "success")
                {
                    if (model.SaveType == "partial")
                    {
                        return Json(new { RoomDetailsInfo = positionSetRes.mPosition[0].RoomDetailsInfo, PositionId = positionSetRes.mPosition[0].PositionId });
                    }
                    else
                    {
                        return Json(positionSetRes.ResponseStatus);
                    }
                }
                else
                {
                    if (model.SaveType == "partial")
                    {
                        return Json(new { RoomDetailsInfo = positionSetRes.mPosition[0].RoomDetailsInfo, PositionId = positionSetRes.mPosition[0].PositionId });
                    }
                    else
                    {
                        return Json(positionSetRes.ResponseStatus);
                    }
                }

            }
            else
            {
                return Json(new { status = "Invalid" });
            }

        }
Пример #10
0
        // GET: Admin/AccomodationTypes
        public ActionResult Index(string searchTerm, int?accomodationPackageId, int?page)
        {
            page = page ?? 1;
            var accomodationPackages = _context.AccomodationPackages.ToList();
            var model = new AccomodationViewModel()
            {
                Accomodations         = Accomodations(searchTerm, accomodationPackageId, page.Value),
                AccomodationPackages  = accomodationPackages,
                SearchTerm            = searchTerm,
                AccomodationPackageId = accomodationPackageId
            };

            return(View(model));
        }
        // GET: Accomodation
        public ActionResult Index(int accomodationTypeId, int?accomodationPacakageId)
        {
            AccomodationViewModel model = new AccomodationViewModel();

            model.AccomodationPackages = accomodationPackagesService.GetAllAccomodationPackagesbyAccomodationType(accomodationTypeId);

            model.AccomodationType = accomodationTypesService.GetAccomodationTypeById(accomodationTypeId);

            model.selectedAccomodationPackageId = accomodationPacakageId.HasValue ? accomodationPacakageId : model.AccomodationPackages.FirstOrDefault() != null?model.AccomodationPackages.FirstOrDefault().Id : 0;

            model.Accomodations = accomodationService.GetAllAccomodationsByAccomodationPackage(model.selectedAccomodationPackageId.Value);

            return(View(model));
        }
        public async Task <IActionResult> Create(AccomodationViewModel accomodationViewModel)
        {
            if (ModelState.IsValid)
            {
                var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
                var user   = _applicationUserAppService.GetById(userId);

                if (user != null)
                {
                    _accomodationAppService.Add(user.EnvironmentId, accomodationViewModel);
                }

                return(RedirectToAction("Index", "Accomodation"));
            }

            return(View(accomodationViewModel));
        }
Пример #13
0
        //[Route("Quote/Accomodation")]
        public IActionResult Accomodation()
        {
            string QRFID = Request.Query["QRFId"].ToString();
            string PositionId = Request.Query["PositionId"].ToString();
            bool IsClone = Convert.ToBoolean(Request.Query["IsClone"]);
            string SuccessMessage = Request.Query["SuccessMessage"].ToString();
            string ErrorMessage = Request.Query["ErrorMessage"].ToString();

            ViewBag.MenuName = "Accomodation";
            model = new AccomodationViewModel();
            model.MenuViewModel.QRFID = QRFID;
            model.MenuViewModel.PositionId = PositionId;

            #region Get Quote Tour Info Header By QRFId
            NewQuoteViewModel modelQuote = new NewQuoteViewModel();
            modelQuote.QRFID = model.MenuViewModel.QRFID;
            model.TourInfoHeaderViewModel = posLibrary.GetSalesTourInfoHeader(ref modelQuote, token);
            #endregion

            positionGetReq = new PositionGetReq();
            positionGetReq.QRFID = QRFID;
            positionGetReq.PositionId = PositionId;
            positionGetReq.ProductType.Add(new ProductType { ProdType = "Hotel" });
            positionGetReq.IsClone = IsClone;

            positionGetRes = positionProviders.GetPosition(positionGetReq, token).Result;

            model = accomoMapping.AccomodationGet(positionGetRes, ref model, token);

            if (!(string.IsNullOrEmpty(SuccessMessage)))
                TempData["success"] = SuccessMessage;

            if (!(string.IsNullOrEmpty(ErrorMessage)))
                TempData["error"] = ErrorMessage;

            if (string.IsNullOrEmpty(PositionId))
            {
                if (string.IsNullOrEmpty(SuccessMessage) && string.IsNullOrEmpty(ErrorMessage))
                    return View(model);
                else
                    return PartialView("_Accomodation", model);
            }
            else
                return PartialView("_Accomodation", model);
        }
Пример #14
0
        // GET: Accomodation
        public ActionResult Index(string searchTerm, int?typeid, int?packageid)
        {
            AccomodationViewModel model = new AccomodationViewModel();


            model.AccomodationTypes          = accomodationTypesService.GetAllAccomodationTypes();
            model.AccomodationPackages       = accomodationPackagesService.SearchAccomodationPackages(searchTerm, typeid);
            model.searchTerm                 = searchTerm;
            model.CurrentAccomodationType    = typeid;
            model.CurrentAccomodationPackage = packageid;



            model.Accomodations =
                accomodationService.SearchAccomodations(searchTerm, typeid, packageid);
            model.Accomodations.DistinctBy(a => a.AccomodationPackage.Id);
            return(View(model));
        }
        public JsonResult GetReservationByAccomodationId(Guid accomodationId, DateTime startDate, DateTime finishDate)
        {
            if (accomodationId == Guid.Empty)
            {
                return(Json(Conflict()));
            }

            //if (startDate == DateTime.MinValue || finishDate == DateTime.MinValue)
            //    return Json(Conflict());

            //if (startDate >= finishDate)
            //    return Json(Conflict());

            AccomodationViewModel accomodationVM = _accomodationAppService.GetAccomodationAndCulturalExchangeList(accomodationId);

            if (accomodationVM == null)
            {
                return(Json(NotFound()));
            }

            return(Json(Ok(accomodationVM.CulturalExchangeViewModel)));
        }
        protected override void Edit()
        {
            if (CurrentAccomodation != null)
            {
                CurrentAccomodation.DateEnd = DateTime.Now;

                oldAccomodation = new AccomodationViewModel
                {
                    AccomodationId = CurrentAccomodation.AccomodationId,
                    StudentId      = CurrentAccomodation.StudentId,
                    StudentName    = CurrentAccomodation.StudentName,
                    RoomId         = CurrentAccomodation.RoomId,
                    RoomNo         = CurrentAccomodation.RoomNo,
                    DateStart      = CurrentAccomodation.DateStart,
                    DateEnd        = CurrentAccomodation.DateEnd
                };
                IsEditing    = true;
                ErrorMessage = string.Empty;
            }
            else
            {
                ErrorMessage = "Не выбран объект для редактирования!";
            }
        }
        public AccomodationViewModel Update(AccomodationViewModel accomodationViewModel)
        {
            var accomodation = _mapper.Map <Accomodation>(accomodationViewModel);

            return(_mapper.Map <AccomodationViewModel>(_accomodationService.Update(accomodation)));
        }
        protected bool Validate(AccomodationViewModel accomodation)
        {
            // При добавлении новой записи
            if (IsAdding)
            {
                // Проверяем корректность заполнения полей
                if (accomodation.StudentId == 0)
                {
                    ErrorMessage = "Поле Студент не может быть пустым!";
                    return(false);
                }
                else if (accomodation.RoomId == 0)
                {
                    ErrorMessage = "Поле Номер комнаты не может быть пустым!";
                    return(false);
                }

                else if (accomodation.DateStart == null)
                {
                    ErrorMessage = "Поле Дата заселения не может быть пустым!";
                    return(false);
                }

                // Проверяем, нет ли незавершенных записей для этого студента
                var acc = context.Accomodations.Where(
                    p => p.Student.StudentId == CurrentAccomodation.StudentId &&
                    p.DateEnd == null).FirstOrDefault();
                if (acc != null)
                {
                    ErrorMessage = "Студент еще не выселен!";
                    return(false);
                }

                // Проверяем, есть ли свободные места в комнате
                var count = context.Rooms.Where(
                    p => p.RoomId == CurrentAccomodation.RoomId).
                            Select(p => p.Seats).SingleOrDefault();
                var studCount = context.Accomodations.
                                Where(p => p.Room.RoomId == CurrentAccomodation.RoomId &&
                                      p.DateEnd == null).Count();

                if (count == studCount)
                {
                    ErrorMessage = "В этой комнате нет свободных мест!";
                    return(false);
                }
            }

            // При редактировании записи
            if (IsEditing)
            {
                // Проверяем, заполнена ли дата выселения
                if (accomodation.DateEnd == null)
                {
                    ErrorMessage = "Поле Дата выселения не может быть пустым!";
                    return(false);
                }
            }

            ErrorMessage = string.Empty;
            return(true);
        }
Пример #19
0
        public bool BindAccomodationMasterData(IConfiguration _configuration, string token, ref AccomodationViewModel model, int totalRecord)
        {
            ProductAttributeReq objProductAttributeReq;
            ProductAttributeRes objProductAttributeRes;

            //bool GetStatus = false;

            //#region Get Quote Info By QRFId
            //NewQuoteViewModel modelQuote = new NewQuoteViewModel();
            //modelQuote.QRFID = model.MenuViewModel.QRFID;
            //SalesQuoteLibrary quoteLibrary = new SalesQuoteLibrary(_configuration);
            //GetStatus = salesQuoteLibrary.GetQRFAgentByQRFId(_configuration, token, ref modelQuote);
            ////if (GetStatus)
            ////{
            ////    model.TourInfoHeaderViewModel = modelQuote.TourInfoHeaderViewModel;
            ////}
            //#endregion

            // #region Bind StartingFrom and NoOfNights
            //var objAccomodationData = new AccomodationData();
            //  List<AttributeValues> listSF = new List<AttributeValues>();
            //  List<AttributeValues> listNON = new List<AttributeValues>();

            //if (modelQuote.mdlQuoteAgentInfoViewModel.Duration > 0)
            //{
            //    for (int i = 1; i <= modelQuote.mdlQuoteAgentInfoViewModel.Duration; i++)
            //    {
            //       // listSF.Add(new AttributeValues { AttributeValue_Id = i.ToString(), Value = "Day " + i });
            //        listNON.Add(new AttributeValues { AttributeValue_Id = i.ToString(), Value = i.ToString() });
            //    }
            // //   listSF.Add(new AttributeValues { AttributeValue_Id = (modelQuote.mdlQuoteAgentInfoViewModel.Duration + 1).ToString(), Value = "Day " + (modelQuote.mdlQuoteAgentInfoViewModel.Duration + 1) });
            //}
            //else
            //{
            //   // listSF.Add(new AttributeValues { AttributeValue_Id = "1", Value = "Day 1" });
            //    listNON.Add(new AttributeValues { AttributeValue_Id = "1", Value = "1" });
            //}

            //   #endregion

            #region Bind Hotel category
            var objCategory = new List <ProdCatDefProperties>();

            objProductAttributeReq = new ProductAttributeReq();
            objProductAttributeReq.AttributeName = "Budgetprice Category";
            objProductAttributeRes = objMasterProviders.GetProdAttributeDetailsByNameOrVal(objProductAttributeReq, token).Result;

            if (objProductAttributeRes.ResponseStatus.Status == "Success" && objProductAttributeRes.ProductAttributeDetails.Count > 0)
            {
                objCategory = objProductAttributeRes.ProductAttributeDetails.Select(a => new ProdCatDefProperties
                {
                    VoyagerDefProductCategoryId = a.AttributeId + "|" + a.Value,
                    Name = a.Value
                }).ToList();
            }

            //ProdCatDefGetReq objProdCatDefGetReq = new ProdCatDefGetReq();
            //ProdCatDefGetRes objProdCatDefGetRes = objMasterProviders.GetProdCatDefByName(objProdCatDefGetReq, token).Result;

            //if (objProdCatDefGetRes.ResponseStatus.Status == "Success" && objProdCatDefGetRes.ProdCatDefProperties.Count > 0)
            //{
            //    //objCategory = objProdCatDefGetRes.ProdCatDefProperties;
            //    objCategory = objProdCatDefGetRes.ProdCatDefProperties.Select(a => new ProdCatDefProperties
            //    {
            //        VoyagerDefProductCategoryId = a.VoyagerDefProductCategoryId + "|" + a.Name,
            //        Name = a.Name
            //    }).ToList();
            //}
            #endregion

            #region Bind Hotel Star Rating
            var objStarRating = new List <ProductAttributeDetails>();

            objProductAttributeReq = new ProductAttributeReq();
            objProductAttributeReq.AttributeName = "StarRating";
            objProductAttributeRes = objMasterProviders.GetProdAttributeDetailsByNameOrVal(objProductAttributeReq, token).Result;

            if (objProductAttributeRes.ResponseStatus.Status == "Success" && objProductAttributeRes.ProductAttributeDetails.Count > 0)
            {
                objStarRating = objProductAttributeRes.ProductAttributeDetails;
            }
            #endregion

            #region Bind Hotel Location
            var objLocation = new List <ProductAttributeDetails>();

            objProductAttributeReq = new ProductAttributeReq();
            objProductAttributeReq.AttributeName = "Location";
            objProductAttributeRes = objMasterProviders.GetProdAttributeDetailsByNameOrVal(objProductAttributeReq, token).Result;

            if (objProductAttributeRes.ResponseStatus.Status == "Success" && objProductAttributeRes.ProductAttributeDetails.Count > 0)
            {
                objLocation = objProductAttributeRes.ProductAttributeDetails;
            }
            #endregion

            #region Meal Plan
            //var objMealPlan = new List<ProductAttributeDetails>();

            //objProductAttributeReq = new ProductAttributeReq();
            //objProductAttributeReq.AttributeName = "Board";
            //objProductAttributeRes = objMasterProviders.GetProdAttributeDetailsByNameOrVal(objProductAttributeReq, token).Result;

            //if (objProductAttributeRes.ResponseStatus.Status == "Success" && objProductAttributeRes.ProductAttributeDetails.Count > 0)
            //{
            //    objMealPlan = objProductAttributeRes.ProductAttributeDetails;
            //}

            var objMealPlan = new List <ProductAttributeDetails>();

            var defMealPlanGetReq = new DefMealPlanGetReq();
            defMealPlanGetReq.Status = "false";
            DefMealPlanGetRes objDefMealPlanGetRes = objMasterProviders.GetDefMealPlan(defMealPlanGetReq, token).Result;

            if (objDefMealPlanGetRes.ResponseStatus.Status == "Success" && objDefMealPlanGetRes.mDefMealPlan.Count > 0)
            {
                objMealPlan = objDefMealPlanGetRes.mDefMealPlan.Select(a => new ProductAttributeDetails {
                    AttributeId = a.MealPlan, Value = a.Description
                }).ToList();
            }
            #endregion

            #region Bind Keep As
            var objKeepAs = new List <AttributeValues>();

            MasterTypeRequest objMasterTypeRequest = new MasterTypeRequest();
            objMasterTypeRequest.Property = "QRF Masters";
            objMasterTypeRequest.Name     = "Position Type";

            SalesProviders     objSalesProvider      = new SalesProviders(_configuration);
            MasterTypeResponse objMasterTypeResponse = objSalesProvider.GetGenericMasterForType(objMasterTypeRequest, token).Result;

            if (objMasterTypeResponse.Status == "Success" && objMasterTypeResponse.PropertyList.Count > 0)
            {
                if (objMasterTypeResponse.PropertyList[0].Attribute[0].AttributeName == "Position Type")
                {
                    objKeepAs = objMasterTypeResponse.PropertyList[0].Attribute[0].Values.ToList();
                }
            }
            #endregion

            for (int i = 0; i < totalRecord; i++)
            {
                //  model.AccomodationData[i].StartingFromList = listSF;
                // model.AccomodationData[i].NoOfNightList = listNON;
                model.AccomodationData[i].CategoryList   = objCategory;
                model.AccomodationData[i].StarRatingList = objStarRating;
                model.AccomodationData[i].LocationList   = objLocation;
                model.AccomodationData[i].MealPlanList   = objMealPlan;
                model.AccomodationData[i].KeepAsList     = objKeepAs;
            }

            return(true);
        }
Пример #20
0
 //Accomodation - > Model
 public static Accomodation ToModelAccomodations(AccomodationViewModel accomodationViewModel)
 {
     return(Mapper.Map <AccomodationViewModel, Accomodation>(accomodationViewModel));
 }
Пример #21
0
        // GET: Accomodations/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Accomodation accomodation = db.Accomodations.Find(id);

            if (accomodation == null)
            {
                return(HttpNotFound());
            }

            var parking     = "";
            var petfriendly = "";
            var furnished   = "";

            if (accomodation.Parking == true)
            {
                parking = "Yes";
            }
            else
            {
                parking = "No";
            }

            if (accomodation.PetFriendly == true)
            {
                petfriendly = "Yes";
            }
            else
            {
                petfriendly = "No";
            }

            if (accomodation.Furnished == true)
            {
                furnished = "Yes";
            }
            else
            {
                furnished = "No";
            }

            AccomodationViewModel vm = new AccomodationViewModel();

            vm.Id              = accomodation.Id;
            vm.UserId          = accomodation.UserId;
            vm.Posted_Date     = accomodation.Posted_Date;
            vm.Number_of_Rooms = accomodation.Number_of_Rooms;
            vm.Rent            = accomodation.Rent;
            vm.Petfriendlyval  = petfriendly;
            vm.parkingval      = parking;
            vm.Floor           = accomodation.Floor;
            vm.furnishedval    = furnished;
            vm.Location        = accomodation.Location;
            vm.Description     = accomodation.Description;
            vm.Last_Updated    = accomodation.Last_Updated;
            vm.Images          = accomodation.AccomodationImages.Where(t => t.AccomodationId == accomodation.Id).ToList();
            return(View(vm));
        }