コード例 #1
0
        public WorkerSelection(HairSalon hairSalon)
        {
            InitializeComponent();

            workerApi = new WorkerApiClient();

            this.hairSalon = hairSalon;
        }
コード例 #2
0
        public ServiceManagement(HairSalon hairSalon)
        {
            InitializeComponent();

            serviceApi = new ServiceApiClient();

            this.hairSalon = hairSalon;
        }
コード例 #3
0
        public WorkingHourManagement(HairSalon hairSalon)
        {
            InitializeComponent();

            workingHourApi = new WorkingHourApiClient();

            this.hairSalon = hairSalon;
        }
コード例 #4
0
        public MethodOfPaymentManagement(HairSalon hairSalon)
        {
            InitializeComponent();

            methodOfPaymentApi = new MethodOfPaymentApiClient();

            this.hairSalon = hairSalon;
        }
コード例 #5
0
ファイル: HomeController.cs プロジェクト: mucnjakf/SisanjeHR
        public async Task <ActionResult> HairSalonDetails(int id)
        {
            hairSalonApi = new HairSalonApiClient();

            HairSalon hairSalon = await hairSalonApi.GetHairSalon(id);

            return(View(hairSalon));
        }
コード例 #6
0
        public bool DeleteHairSalon(int id)
        {
            HairSalon hairSalon = unitOfWork.HairSalons.Get(id);

            unitOfWork.HairSalons.Remove(hairSalon);

            int success = unitOfWork.Complete();

            return(success > 0);
        }
コード例 #7
0
        public void UnfavoriteHairSalon(FavoriteHairSalonVM favoriteHairSalonVM)
        {
            HairSalon      hairSalon      = unitOfWork.HairSalons.GetHairSalon(favoriteHairSalonVM.HairSalonId);
            RegisteredUser registeredUser = unitOfWork.RegisteredUsers.Get(favoriteHairSalonVM.RegisteredUser.Id);

            FavoriteHairSalons favoriteHairSalon = unitOfWork.FavoriteHairSalons.GetFavoriteHairSalonByRegisteredUserAndHairSalon(registeredUser.Id, hairSalon.Id);

            unitOfWork.FavoriteHairSalons.Remove(favoriteHairSalon);
            unitOfWork.Complete();
        }
コード例 #8
0
        public WorkerSelectionPanel(Worker worker, HairSalon hairSalon)
        {
            InitializeComponent();

            workerApi = new WorkerApiClient();

            this.worker    = worker;
            this.hairSalon = hairSalon;

            SetWorkerValues();
        }
コード例 #9
0
        public async Task <ActionResult> Edit(int id)
        {
            appointmentApi = new AppointmentApiClient();
            hairSalonApi   = new HairSalonApiClient();

            Appointment appointment = await appointmentApi.GetAppointment(id);

            HairSalon hairSalon = await hairSalonApi.GetHairSalon(appointment.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()
                });
            }

            AppointmentUpdateVM appointmentUpdateVM = new AppointmentUpdateVM()
            {
                Date           = appointment.Date,
                Time           = appointment.Time,
                Workers        = new SelectList(workers, "Value", "Text"),
                SelectedWorker = new SelectListItem()
                {
                    Value = appointment.Worker.Id.ToString(), Text = appointment.Worker.GetFullName()
                },
                AvailableServices = new SelectList(services, "Value", "Text"),
                MethodsOfPayment  = new SelectList(methodsOfPayment, "Value", "Text"),
                HairSalonId       = hairSalon.Id
            };

            return(View(appointmentUpdateVM));
        }
コード例 #10
0
        public HairSalonPanel(HairSalon hairSalon)
        {
            InitializeComponent();

            ls = new LoadingScreen();

            hairSalonApi = new HairSalonApiClient();

            this.hairSalon = hairSalon;

            SetHairSalonValues();
        }
コード例 #11
0
        public EditHairSalon(HairSalon hairSalon)
        {
            InitializeComponent();

            ls = new LoadingScreen();

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

            this.hairSalon = hairSalon;

            SetHairSalonValues();
        }
コード例 #12
0
        public MethodOfPaymentPanel(MethodOfPayment methodOfPayment, HairSalon hairSalon)
        {
            InitializeComponent();

            ls = new LoadingScreen();

            methodOfPaymentApi           = new MethodOfPaymentApiClient();
            hairSalonMethodsOfPaymentApi = new HairSalonMethodsOfPaymentApiClient();

            this.methodOfPayment = methodOfPayment;
            this.hairSalon       = hairSalon;

            SetMethodOfPaymentValues();
        }
コード例 #13
0
        public ShowHairSalon(HairSalon hairSalon)
        {
            InitializeComponent();

            ownerApi = new OwnerApiClient();
            hairSalonMethodsOfPaymentApi = new HairSalonMethodsOfPaymentApiClient();
            hairSalonWorkingHoursApi     = new HairSalonWorkingHoursApiClient();
            workerApi            = new WorkerApiClient();
            hairSalonServicesApi = new HairSalonServicesApiClient();

            this.hairSalon = hairSalon;

            SetHairSalonValues();
        }
コード例 #14
0
        public void FavoriteHairSalon(FavoriteHairSalonVM favoriteHairSalonVM)
        {
            HairSalon      hairSalon      = unitOfWork.HairSalons.GetHairSalon(favoriteHairSalonVM.HairSalonId);
            RegisteredUser registeredUser = unitOfWork.RegisteredUsers.Get(favoriteHairSalonVM.RegisteredUser.Id);

            FavoriteHairSalons favoriteHairSalon = new FavoriteHairSalons()
            {
                HairSalonId      = hairSalon.Id,
                RegisteredUserId = registeredUser.Id
            };

            unitOfWork.FavoriteHairSalons.Add(favoriteHairSalon);
            unitOfWork.Complete();
        }
コード例 #15
0
        public ServicePanel(Service service, HairSalon hairSalon)
        {
            InitializeComponent();

            ls = new LoadingScreen();

            serviceApi           = new ServiceApiClient();
            hairSalonServicesApi = new HairSalonServicesApiClient();

            this.service   = service;
            this.hairSalon = hairSalon;

            SetServiceValues();
        }
コード例 #16
0
        public WorkingHourPanel(WorkingHour workingHour, HairSalon hairSalon)
        {
            InitializeComponent();

            ls = new LoadingScreen();

            workingHourApi           = new WorkingHourApiClient();
            hairSalonWorkingHoursApi = new HairSalonWorkingHoursApiClient();

            this.workingHour = workingHour;
            this.hairSalon   = hairSalon;

            SetWorkingHourValues();
        }
コード例 #17
0
        public async Task <bool> CheckIfClientIsOwnerAsync(HairSalon hairSalon)
        {
            var userId = _currentUserService.UserId;

            var user = await _userManager.FindByIdAsync(userId);

            var isClient = await _userManager.IsInRoleAsync(user, RolesEnum.Client);

            if (isClient && user.Email == hairSalon.Email)
            {
                return(true);
            }

            return(false);
        }
コード例 #18
0
        public async Task <HairSalon> GetHairSalon(int id)
        {
            HttpClient request = new HttpClient();

            request.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(HEAD));

            HttpResponseMessage response = await request.GetAsync($"{ API_URL }/GetHairSalon/{ id }");

            if (response.IsSuccessStatusCode)
            {
                HairSalon result = await response.Content.ReadAsAsync <HairSalon>();

                return(result);
            }
            return(new HairSalon());
        }
コード例 #19
0
        public bool InsertAppointment(AppointmentInsertVM appointmentInsertVM)
        {
            HairSalon       hairSalon       = unitOfWork.HairSalons.Get(appointmentInsertVM.HairSalonId);
            RegisteredUser  registeredUser  = unitOfWork.RegisteredUsers.Get(appointmentInsertVM.RegisteredUser.Id);
            Worker          worker          = unitOfWork.Workers.Get(appointmentInsertVM.Worker.Id);
            MethodOfPayment methodOfPayment = unitOfWork.MethodsOfPayment.Get(appointmentInsertVM.MethodOfPayment.Id);

            string   newTime    = appointmentInsertVM.Time.ToString("hh':'mm");
            TimeSpan newierTime = TimeSpan.Parse(newTime);

            Appointment appointment = new Appointment()
            {
                Date            = appointmentInsertVM.Date,
                Time            = newierTime,
                IsCompleted     = false,
                HairSalon       = hairSalon,
                RegisteredUser  = registeredUser,
                Worker          = worker,
                MethodOfPayment = methodOfPayment
            };

            decimal sum = 0;

            foreach (Service service in appointmentInsertVM.Services)
            {
                sum += service.Price;
            }
            appointment.TotalPrice = sum;

            unitOfWork.Appointments.Add(appointment);
            unitOfWork.Complete();

            Appointment appointmentForService = unitOfWork.Appointments.GetAppointment(appointment.Date, appointment.Time);

            foreach (Service service in appointmentInsertVM.Services)
            {
                Service serviceForAppointment = unitOfWork.Services.Get(service.Id);
                unitOfWork.AppointmentServices.Add(new AppointmentServices()
                {
                    Appointment = appointmentForService, Service = serviceForAppointment
                });
            }

            int success = unitOfWork.Complete();

            return(success > 0);
        }
コード例 #20
0
        public bool UpdateReview(ReviewUpdateVM reviewUpdateVM)
        {
            RegisteredUser registeredUser = unitOfWork.RegisteredUsers.Get(reviewUpdateVM.RegisteredUser.Id);
            HairSalon      hairSalon      = unitOfWork.HairSalons.GetHairSalon(reviewUpdateVM.HairSalonId);

            Review review = unitOfWork.Reviews.GetReview(reviewUpdateVM.Id);

            review.Content          = reviewUpdateVM.Content;
            review.Rating           = reviewUpdateVM.Rating;
            review.Date             = reviewUpdateVM.Date;
            review.HairSalonId      = hairSalon.Id;
            review.RegisteredUserId = registeredUser.Id;

            int success = unitOfWork.Complete();

            return(success > 0);
        }
コード例 #21
0
        public bool InsertAppointmentByUser(AppointmentInsertVM appointmentInsertVM)
        {
            HairSalon       hairSalon       = unitOfWork.HairSalons.Get(appointmentInsertVM.HairSalonId);
            RegisteredUser  registeredUser  = unitOfWork.RegisteredUsers.Get(appointmentInsertVM.RegisteredUser.Id);
            Worker          worker          = unitOfWork.Workers.Get(int.Parse(appointmentInsertVM.SelectedWorkerId));
            MethodOfPayment methodOfPayment = unitOfWork.MethodsOfPayment.Get(int.Parse(appointmentInsertVM.SelectedMethodOfPaymentId));

            Appointment appointment = new Appointment()
            {
                Date            = appointmentInsertVM.Date,
                Time            = appointmentInsertVM.Time,
                IsCompleted     = false,
                HairSalon       = hairSalon,
                RegisteredUser  = registeredUser,
                Worker          = worker,
                MethodOfPayment = methodOfPayment
            };

            decimal sum = 0;

            foreach (int serviceId in appointmentInsertVM.SelectedServices)
            {
                Service serviceForAppointment = unitOfWork.Services.Get(serviceId);
                sum += serviceForAppointment.Price;
            }
            appointment.TotalPrice = sum;

            unitOfWork.Appointments.Add(appointment);
            unitOfWork.Complete();

            Appointment appointmentForService = unitOfWork.Appointments.GetAppointment(appointment.Id);

            foreach (int serviceId in appointmentInsertVM.SelectedServices)
            {
                Service serviceForAppointment = unitOfWork.Services.Get(serviceId);
                unitOfWork.AppointmentServices.Add(new AppointmentServices()
                {
                    AppointmentId = appointmentForService.Id, ServiceId = serviceForAppointment.Id
                });
            }

            int success = unitOfWork.Complete();

            return(success > 0);
        }
コード例 #22
0
        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));
        }
コード例 #23
0
        public bool InsertHairSalon(HairSalonInsertVM hairSalonInsertVM)
        {
            Owner owner = unitOfWork.Owners.Get(hairSalonInsertVM.OwnerId);

            string  inputAddress  = hairSalonInsertVM.Address;
            string  inputCityName = hairSalonInsertVM.City;
            Country inputCountry  = hairSalonInsertVM.Country;

            Country country = unitOfWork.Countries.Get(inputCountry.Id);

            bool cityExists = unitOfWork.Cities.Exists(inputCityName, country.Id);

            City city = cityExists ?
                        unitOfWork.Cities.GetCityWithCountry(inputCityName, country.Id) :
                        new City()
            {
                Name = inputCityName, Country = country
            };

            bool locationExists = unitOfWork.Locations.Exists(inputAddress, city.Id, city.Country.Id);

            DataAccessLayer.Models.Location location = locationExists ?
                                                       unitOfWork.Locations.GetLocationWithCity(inputAddress, city.Id, city.Country.Id) :
                                                       new DataAccessLayer.Models.Location()
            {
                Address = inputAddress, City = city
            };

            HairSalon hairSalon = new HairSalon()
            {
                Name        = hairSalonInsertVM.Name,
                Description = hairSalonInsertVM.Description,
                Location    = location,
                Owner       = owner
            };

            unitOfWork.HairSalons.Add(hairSalon);

            int success = unitOfWork.Complete();

            return(success > 0);
        }
コード例 #24
0
        public bool InsertReview(ReviewInsertVM reviewInsertVM)
        {
            RegisteredUser registeredUser = unitOfWork.RegisteredUsers.Get(reviewInsertVM.RegisteredUser.Id);
            HairSalon      hairSalon      = unitOfWork.HairSalons.GetHairSalon(reviewInsertVM.HairSalonId);

            Review review = new Review()
            {
                Content        = reviewInsertVM.Content,
                Rating         = reviewInsertVM.Rating,
                RegisteredUser = registeredUser,
                HairSalon      = hairSalon,
                Date           = reviewInsertVM.Date
            };

            unitOfWork.Reviews.Add(review);

            int success = unitOfWork.Complete();

            return(success > 0);
        }
コード例 #25
0
        private async Task LoadAppointmentsToStackPanel(object sender)
        {
            SpAppointments.Children.Clear();

            HairSalon hairSalon = (HairSalon)CbHairSalons.SelectedItem;

            List <Appointment> appointments = await appointmentApi.GetAppointmentsByHairSalon(hairSalon.Id);

            var calendar = sender as Calendar;

            if (appointments.Count > 0)
            {
                foreach (Appointment appointment in appointments)
                {
                    if (calendar.SelectedDate.HasValue && calendar.SelectedDate.Value == appointment.Date)
                    {
                        AppointmentPanelMini appointmentPanelMini = new AppointmentPanelMini(appointment);

                        SpAppointments.Children.Add(appointmentPanelMini);
                    }
                }
            }
        }
コード例 #26
0
        public List <FreeTermDto> GetFreeTerms(HairSalon hairSalon)
        {
            var workingHours = hairSalon.WorkingHours.ToList();

            if (!workingHours.Any())
            {
                throw new Exception("Sport object doesn't have working hours");
            }

            var futureDays   = 7;
            var reservations = hairSalon.Reservations
                               .Where(r => r.Date >= DateTime.Today && r.Date <= DateTime.Today.AddDays(futureDays))
                               .ToList();

            var freeTerms = new List <FreeTermDto>();

            for (int i = 0; i <= futureDays; i++)
            {
                var date           = DateTime.Today.AddDays(i);
                var day            = (int)date.DayOfWeek == 0 ? 7 : (int)date.DayOfWeek;
                var wh             = workingHours.Find(w => w.Day == day);
                var openTimeHours  = wh.OpenTime.Hours;
                var closeTimeHours = wh.CloseTime.Hours;

                if (closeTimeHours == 0)
                {
                    closeTimeHours = 24;
                }

                for (int j = openTimeHours; j < closeTimeHours; j++)
                {
                    var startTime = new TimeSpan(j, 0, 0);
                    var endTime   = startTime.Add(TimeSpan.FromHours(1));

                    if (startTime.Hours == 23)
                    {
                        endTime = new TimeSpan(0, 0, 0);
                    }

                    var freeTerm1 = new FreeTermDto
                    {
                        Date      = date,
                        StartTime = startTime,
                    };

                    var freeTerm2 = new FreeTermDto
                    {
                        Date      = date,
                        StartTime = new TimeSpan(j, 30, 0),
                    };

                    freeTerms.Add(freeTerm1);
                    freeTerms.Add(freeTerm2);
                }
            }

            List <FreeTermDto> output = new List <FreeTermDto>();

            foreach (var ft in freeTerms)
            {
                output.Add(ft);

                foreach (var res in reservations)
                {
                    if (ft.Date == res.Date && ft.StartTime == res.StartTime)
                    {
                        output.Remove(ft);
                    }
                }
            }

            return(output);
        }
コード例 #27
0
        public List <TermByDateDto> GetAllTerms(HairSalon hairSalon)
        {
            var workingHours = hairSalon.WorkingHours.ToList();

            if (!workingHours.Any())
            {
                throw new Exception("Sport object doesn't have working hours");
            }

            var futureDays   = 7;
            var reservations = hairSalon.Reservations
                               .Where(r => r.Date >= DateTime.Today && r.Date <= DateTime.Today.AddDays(futureDays))
                               .ToList();

            var termsByDate = new List <TermByDateDto>();

            for (int i = 0; i <= futureDays; i++)
            {
                var date           = DateTime.Today.AddDays(i);
                var day            = (int)date.DayOfWeek == 0 ? 7 : (int)date.DayOfWeek;
                var wh             = workingHours.Find(w => w.Day == day);
                var openTimeHours  = wh.OpenTime.Hours;
                var closeTimeHours = wh.CloseTime.Hours;

                if (closeTimeHours == 0)
                {
                    closeTimeHours = 24;
                }

                var termByDate = new TermByDateDto();
                termByDate.Date = date;

                for (int j = openTimeHours; j < closeTimeHours; j++)
                {
                    var startTime = new TimeSpan(j, 0, 0);
                    var endTime   = startTime.Add(TimeSpan.FromHours(1));

                    if (startTime.Hours == 23)
                    {
                        endTime = new TimeSpan(0, 0, 0);
                    }

                    var term1 = new TermDto
                    {
                        StartTime = startTime,
                        Status    = "free",
                        IsExpired = false
                    };

                    var term2 = new TermDto
                    {
                        StartTime = new TimeSpan(j, 30, 0),
                        Status    = "free",
                        IsExpired = false
                    };

                    termByDate.Terms.Add(term1);
                    termByDate.Terms.Add(term2);
                }

                termsByDate.Add(termByDate);
            }


            foreach (var res in reservations)
            {
                foreach (var termByDate in termsByDate)
                {
                    foreach (var term in termByDate.Terms)
                    {
                        if (termByDate.Date == res.Date && term.StartTime == res.StartTime)
                        {
                            term.Status = res.Status.Status;
                        }

                        if (termByDate.Date == DateTime.Today && term.StartTime < DateTime.Now.TimeOfDay)
                        {
                            term.Status = Status.Accepted;
                        }
                    }
                }
            }

            return(termsByDate);
        }
コード例 #28
0
        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));
        }