Esempio n. 1
0
        public async Task <ActionResult> Create(int id)
        {
            hairSalonApi = new HairSalonApiClient();

            ReviewInsertVM reviewInsertVM = new ReviewInsertVM
            {
                HairSalonId = id,
                HairSalon   = await hairSalonApi.GetHairSalon(id)
            };

            return(View(reviewInsertVM));
        }
Esempio n. 2
0
        public EditHairSalon(HairSalon hairSalon)
        {
            InitializeComponent();

            ls = new LoadingScreen();

            countryApi   = new CountryApiClient();
            hairSalonApi = new HairSalonApiClient();

            this.hairSalon = hairSalon;

            SetHairSalonValues();
        }
Esempio n. 3
0
        public async Task <ActionResult> FavoriteHairSalon(int id)
        {
            hairSalonApi = new HairSalonApiClient();

            RegisteredUser registeredUser = (RegisteredUser)Session["RegisteredUser"];

            FavoriteHairSalonVM favoriteHairSalonVM = new FavoriteHairSalonVM()
            {
                RegisteredUser = registeredUser,
                HairSalonId    = id
            };

            await hairSalonApi.FavoriteHairSalon(favoriteHairSalonVM);

            return(RedirectToAction("HairSalonDetails", new { id }));
        }
        public async Task <ActionResult> Create(int hairSalonId)
        {
            hairSalonApi = new HairSalonApiClient();

            HairSalon hairSalon = await hairSalonApi.GetHairSalon(hairSalonId);

            List <SelectListItem> workers          = new List <SelectListItem>();
            List <SelectListItem> services         = new List <SelectListItem>();
            List <SelectListItem> methodsOfPayment = new List <SelectListItem>();

            foreach (var worker in hairSalon.Workers)
            {
                workers.Add(new SelectListItem()
                {
                    Value = worker.Id.ToString(), Text = worker.GetFullName()
                });
            }

            foreach (var hairSalonService in hairSalon.HairSalonServices)
            {
                services.Add(new SelectListItem()
                {
                    Value = hairSalonService.ServiceId.ToString(), Text = hairSalonService.Service.ToString()
                });
            }

            foreach (var hairSalonMethodsOfPayment in hairSalon.HairSalonMethodsOfPayment)
            {
                methodsOfPayment.Add(new SelectListItem()
                {
                    Value = hairSalonMethodsOfPayment.MethodOfPaymentId.ToString(), Text = hairSalonMethodsOfPayment.MethodOfPayment.ToString()
                });
            }

            AppointmentInsertVM appointmentInsertVM = new AppointmentInsertVM()
            {
                HairSalonId       = hairSalonId,
                Workers           = new SelectList(workers, "Value", "Text"),
                AvailableServices = new SelectList(services, "Value", "Text"),
                MethodsOfPayment  = new SelectList(methodsOfPayment, "Value", "Text")
            };

            return(View(appointmentInsertVM));
        }
Esempio n. 5
0
        public async Task <ActionResult> Edit(ReviewUpdateVM reviewUpdateVM)
        {
            reviewApi = new ReviewApiClient();

            if (ModelState.IsValid)
            {
                reviewUpdateVM.RegisteredUser = (RegisteredUser)Session["RegisteredUser"];
                reviewUpdateVM.Date           = DateTime.Now;

                await reviewApi.UpdateReview(reviewUpdateVM);

                return(RedirectToAction("UserProfile", "Account"));
            }

            hairSalonApi = new HairSalonApiClient();

            reviewUpdateVM.HairSalon = await hairSalonApi.GetHairSalon(reviewUpdateVM.HairSalonId);

            return(View(reviewUpdateVM));
        }
Esempio n. 6
0
        public async Task <ActionResult> Create(ReviewInsertVM reviewInsertVM)
        {
            if (ModelState.IsValid)
            {
                reviewApi = new ReviewApiClient();

                reviewInsertVM.RegisteredUser = (RegisteredUser)Session["RegisteredUser"];
                reviewInsertVM.Date           = DateTime.Now;

                await reviewApi.InsertReview(reviewInsertVM);

                return(RedirectToAction("HairSalonDetails", "Home", new { id = reviewInsertVM.HairSalonId }));
            }

            hairSalonApi = new HairSalonApiClient();

            reviewInsertVM.HairSalon = await hairSalonApi.GetHairSalon(reviewInsertVM.HairSalonId);

            return(View(reviewInsertVM));
        }
Esempio n. 7
0
        public async Task <ActionResult> Search(HairSalonSearchVM hairSalonSearchVM)
        {
            if (ModelState.IsValid)
            {
                Session["SearchQuery"] = $"{hairSalonSearchVM.Address}, {hairSalonSearchVM.City}, {hairSalonSearchVM.SelectedCountry.Substring(5)} - {hairSalonSearchVM.Distance} km";

                hairSalonApi = new HairSalonApiClient();

                List <HairSalon> hairSalonsNearMe = await hairSalonApi.GetHairSalonsNearMe(hairSalonSearchVM);

                return(View("HairSalons", hairSalonsNearMe));
            }

            countryApi = new CountryApiClient();

            List <Country> countries = await countryApi.GetCountries();

            SelectList selectListItemCountries = new SelectList(countries);

            hairSalonSearchVM.Countries = selectListItemCountries;

            return(View(hairSalonSearchVM));
        }
        public async Task <ActionResult> Create(AppointmentInsertVM appointmentInsertVM)
        {
            appointmentApi = new AppointmentApiClient();

            bool appointmentIsNotAvailable = false;

            if (ModelState.IsValid)
            {
                appointmentIsNotAvailable = await appointmentApi.CheckAppointmentAvailability(new CheckAvailabilityVM()
                {
                    Date = appointmentInsertVM.Date, Time = appointmentInsertVM.Time, WorkerId = int.Parse(appointmentInsertVM.SelectedWorkerId)
                });
            }

            if (!appointmentIsNotAvailable)
            {
                if (ModelState.IsValid)
                {
                    RegisteredUser registeredUser = (RegisteredUser)Session["RegisteredUser"];
                    appointmentInsertVM.RegisteredUser = registeredUser;

                    await appointmentApi.InsertAppointmentByUser(appointmentInsertVM);

                    return(RedirectToAction("UserProfile", "Account"));
                }
            }
            else
            {
                ViewBag.Unavailable = "unavailable";
            }

            hairSalonApi = new HairSalonApiClient();

            HairSalon hairSalon = await hairSalonApi.GetHairSalon(appointmentInsertVM.HairSalonId.Value);

            List <SelectListItem> workers          = new List <SelectListItem>();
            List <SelectListItem> services         = new List <SelectListItem>();
            List <SelectListItem> methodsOfPayment = new List <SelectListItem>();

            foreach (var worker in hairSalon.Workers)
            {
                workers.Add(new SelectListItem()
                {
                    Value = worker.Id.ToString(), Text = worker.GetFullName()
                });
            }

            foreach (var hairSalonService in hairSalon.HairSalonServices)
            {
                services.Add(new SelectListItem()
                {
                    Value = hairSalonService.ServiceId.ToString(), Text = hairSalonService.Service.ToString()
                });
            }

            foreach (var hairSalonMethodsOfPayment in hairSalon.HairSalonMethodsOfPayment)
            {
                methodsOfPayment.Add(new SelectListItem()
                {
                    Value = hairSalonMethodsOfPayment.MethodOfPaymentId.ToString(), Text = hairSalonMethodsOfPayment.MethodOfPayment.ToString()
                });
            }

            AppointmentInsertVM newAppointmentInsertVM = new AppointmentInsertVM()
            {
                Date              = appointmentInsertVM.Date,
                Time              = appointmentInsertVM.Time,
                HairSalonId       = appointmentInsertVM.HairSalonId.Value,
                Workers           = new SelectList(workers, "Value", "Text"),
                AvailableServices = new SelectList(services, "Value", "Text"),
                MethodsOfPayment  = new SelectList(methodsOfPayment, "Value", "Text")
            };

            return(View(newAppointmentInsertVM));
        }