Esempio n. 1
0
        public bool AddFeedBack(int bookingId, float rate, string comment)
        {
            Bookings booking = _bookingRepository.GetById(bookingId);

            if (booking.Rate != null)
            {
                return(false);
            }

            booking.Rate    = rate;
            booking.Comment = comment;
            _bookingRepository.Update(booking);

            Barbers barber = _barberRepository
                             .GetAll()
                             .Where(b => b.UserId == booking.BarberId)
                             .Include(b => b.Bookings)
                             .First();
            var totalRates = barber.Bookings.Sum(barberBooking => barberBooking.Rate).GetValueOrDefault();
            var totalCount = barber.Bookings.Count(barberBooking => barberBooking.Rate != null);

            barber.OverallRate = totalRates / totalCount;
            barber.RatingCount = totalCount;
            _barberRepository.Update(barber);

            return(true);
        }
Esempio n. 2
0
        private async Task ExecuteSelectedItemCommand(Barbers barber)
        {
            try
            {
                if (barber is null)
                {
                    return;
                }

                if (IsBusy)
                {
                    return;
                }

                SelectedBarberId = barber.Id;

                IsBusy = true;

                using (var Dialog = UserDialogs.Instance.Loading("", null, null, true, MaskType.Black))
                {
                    var navParams = new NavigationParameters();
                    navParams.Add("Barber", barber);
                    await NavigationService.NavigateAsync($"{nameof(DetailPage)}", navParams);
                }
            }
            catch (Exception) { }
            finally
            {
                IsBusy = false;
            }
        }
Esempio n. 3
0
        public Barbers GetBarberInfo(string username)
        {
            Barbers barber = _barberRepository
                             .GetAll()
                             .Where(b => b.Username == username)
                             .Include(b => b.CityCodeNavigation)
                             .Include(b => b.DistrictCodeNavigation)
                             .Include(b => b.User)
                             .ThenInclude(user => user.PaymentMethods)
                             .First();

            return(barber);
        }
Esempio n. 4
0
        public Barbers RegisterBarber(string username, string fullName, string phone)
        {
            AspNetUsers user = _aspNetUserRepository.RegisterUser(username, fullName, phone);

            if (user == null)
            {
                return(null);
            }

            Barbers barber = new Barbers
            {
                UserId       = user.Id,
                Username     = user.UserName,
                FullName     = user.FullName,
                Address      = "address",
                ContactPhone = phone,
                CityCode     = "79",
                DistrictCode = "760",
                IsActive     = true
            };
            var rs = _barberRepository.Add(barber);

            //Create a stub user for barber
            Customers customer = new Customers
            {
                UserId    = user.Id,
                Username  = user.UserName,
                Address   = "address",
                FirstName = user.FullName,
                IsActive  = true
            };

            _customerRepository.Add(customer);

            //Create payment methods
            _paymentMethodRepository.CreatePaymentMethodsForNewUser(user.Id);

            return(rs);
        }
Esempio n. 5
0
        public bool CheckinSlot(int bookingId, double longitude, double latitude,
                                out Dictionary <DateTimeOffset, List <TimePoint> > suggestTimes)
        {
            suggestTimes = null;

            Bookings booking = _bookingRepository.GetBooking(bookingId, true);

            //Check location
            Barbers barber   = booking.Barber;
            double  distance = LocationUtil.CalculateDistance(longitude, latitude,
                                                              barber.Longitude.GetValueOrDefault(), barber.Latitude.GetValueOrDefault());

            if (distance > LocationUtil.AcceptableDistance)
            {
                return(false);
            }

            //Check in-time
            if (booking.State == BookingConstants.Suspended)
            {
                var bookedServices = booking.BookingServices.Select(bs => bs.Service).ToList();
                suggestTimes = GetAvailableSlots(booking.BarberId, new List <DateTimeOffset> {
                    DateTimeUtil.GetToday()
                }, bookedServices);
                return(false);
            }

            //Update state
            if (booking.State == BookingConstants.Booked)
            {
                booking.State = BookingConstants.CheckedIn;
                _bookingRepository.UpdateBooking(booking);
                return(true);
            }

            return(false);
        }
Esempio n. 6
0
        public Barbers GetBarberInfo(string username)
        {
            Barbers barber = _barberService.GetBarberInfo(username);

            return(barber);
        }
Esempio n. 7
0
 public void Save(Barbers barber)
 {
     _barberRepository.Update(barber);
 }
 public void ShowBarber(Barbers barber)
 {
     Console.WriteLine("{0,-20}\t{1,-20}\t{2,-5}\t{3,-20}\t{4,-35}{5,10}\t{6,10}", barber.Name, barber.Surname, barber.Gender, barber.Phone, barber.Email, barber.BirthDate.ToShortDateString(), barber.HireDate.ToShortDateString());
 }