コード例 #1
0
ファイル: CarController.cs プロジェクト: nasro10/Location
 public CarController()
 {
     myService          = new ServiceCar();
     serviceSubCategory = new ServiceSubCategory();
     serviceCarModel    = new ServiceCarModel();
     serviceCreation    = new ServiceCreationYear();
     serviceType        = new ServiceTypeCar();
     serviceImage       = new ServiceImage();
     serviceRating      = new ServiceRating();
 }
コード例 #2
0
 public HomeClientController()
 {
     myService          = new ServiceCategory();
     serviceCountry     = new ServiceCountry();
     serviceState       = new ServiceState();
     serviceCategory    = new ServiceCategory();
     serviceSubCategory = new ServiceSubCategory();
     serviceCar         = new ServiceCar();
     serviceRating      = new ServiceRating();
     serviceUser        = new ServiceUser();
 }
コード例 #3
0
        public bool ProcessVote(AnswerBm bm, string appUserId)
        {
            var vsEntity = this.vehicleService.GetVehiceService(bm.Id);

            if (vsEntity == null)
            {
                return(false);
            }

            var serviceRating = vsEntity.ServiceRatings.FirstOrDefault(x => x.VehicleServiceId == vsEntity.Id && !x.IsDeleted && x.User.ApplicationUserId == appUserId);

            var user = this.userService.GetUserByAppId(appUserId);

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

            if (serviceRating != null)
            {
                serviceRating.IsDeleted = true;
                var isUpdated = this.vehicleService.Update();

                if (!isUpdated)
                {
                    return(false);
                }
            }

            var newServiceRating = new ServiceRating()
            {
                VehicleService   = vsEntity,
                VehicleServiceId = vsEntity.Id,
                User             = user,
                UserId           = user.Id,
                IsPositive       = bm.IsAccepted,
                Message          = bm.Message
            };

            vsEntity.ServiceRatings.Add(newServiceRating);

            bool isAdded = this.vehicleService.AddServiceRating(newServiceRating);

            if (!isAdded)
            {
                return(false);
            }

            return(true);
        }
コード例 #4
0
        public bool AddServiceRating(ServiceRating serviceRating)
        {
            try
            {
                this.context.ServiceRatings.Add(serviceRating);
                this.context.Commit();
            }
            catch (Exception ex)
            {
                return(this.LogError(ex));
            }

            return(true);
        }
コード例 #5
0
        public async Task <CommandResult <ServiceRatingViewModel> > ExecuteAsync(ServiceRatingViewModel serviceRatingViewModel)
        {
            var getUserId = _httpContextAccessor.HttpContext.User.Identity.Name;
            var userName  = _userManager.FindByIdAsync(getUserId).Result.UserName;

            try
            {
                //Check provider has available
                var getService = await _serviceRepository.FindByIdAsync(Guid.Parse(serviceRatingViewModel.ServiceId));

                if (getService == null)
                {
                    await Logging <AddUpdateRatingServiceCommand>
                    .WarningAsync(ActionCommand.COMMAND_ADD, userName, ErrorMessageConstant.ERROR_CANNOT_FIND_ID);

                    return(new CommandResult <ServiceRatingViewModel>
                    {
                        isValid = false,
                        errorMessage = ErrorMessageConstant.ERROR_CANNOT_FIND_ID
                    });
                }
                var getServiceRating = await _serviceRatingRepository.FindSingleAsync(x => x.ServiceId == Guid.Parse(serviceRatingViewModel.ServiceId) &&
                                                                                      x.UserId == Guid.Parse(serviceRatingViewModel.UserId));

                if (getServiceRating != null)
                {
                    var getUserService = _getOwnServiceInformationQuery.ExecuteAsync(serviceRatingViewModel.ServiceId);
                    getServiceRating.NumberOfRating = serviceRatingViewModel.NumberOfRating;
                    getServiceRating.DateModified   = DateTime.Now;
                    _serviceRatingRepository.Update(getServiceRating);
                    await _serviceRatingRepository.SaveAsync();

                    await LoggingUser <AddUpdateRatingServiceCommand> .
                    InformationAsync(getUserId, userName, userName + "rated"
                                     + getService.ServiceName + " with" + getServiceRating.NumberOfRating);

                    await Logging <AddUpdateRatingServiceCommand> .InformationAsync(ActionCommand.COMMAND_ADD, userName,
                                                                                    JsonConvert.SerializeObject(serviceRatingViewModel));

                    return(new CommandResult <ServiceRatingViewModel>
                    {
                        isValid = true,
                        myModel = serviceRatingViewModel
                    });
                }
                var query = new ServiceRating
                {
                    NumberOfRating = serviceRatingViewModel.NumberOfRating,
                    DateCreated    = DateTime.Now,
                    ServiceId      = Guid.Parse(serviceRatingViewModel.ServiceId),
                    UserId         = Guid.Parse(getUserId)
                };
                await _serviceRatingRepository.Add(query);

                await _serviceRatingRepository.SaveAsync();

                await LoggingUser <AddUpdateRatingServiceCommand> .
                InformationAsync(getUserId, userName, userName + "rated"
                                 + getService.ServiceName + " with" + query.NumberOfRating);

                await Logging <AddUpdateRatingServiceCommand> .InformationAsync(ActionCommand.COMMAND_ADD, userName,
                                                                                JsonConvert.SerializeObject(serviceRatingViewModel));

                return(new CommandResult <ServiceRatingViewModel>
                {
                    isValid = true,
                    myModel = serviceRatingViewModel
                });
            }
            catch (Exception ex)
            {
                await Logging <AddUpdateRatingServiceCommand> .
                ErrorAsync(ex, ActionCommand.COMMAND_ADD, userName, "Has Error");

                return(new CommandResult <ServiceRatingViewModel>
                {
                    isValid = false,
                    errorMessage = ex.InnerException.Message.ToString()
                });
            }
        }
コード例 #6
0
ファイル: RatingsController.cs プロジェクト: nasro10/Location
 public RatingsController()
 {
     myService  = new ServiceRating();
     serviceCar = new ServiceCar();
 }
コード例 #7
0
 public override string ToString()
 {
     return(Name.ToString() + ", " + Address.ToString() + ",  " + Phone.ToString() + ",  " + Time.ToString() + ",  " + Price.ToString() + ",  " + Location.ToString() + ",  " + Cuisine.ToString() + ",  " + FoodRating.ToString() + ",  " + ServiceRating.ToString() + ",  " + AmbienceRating.ToString() + ",  " + ValueRating.ToString() + ",  " + OverallRating.ToString() + ",  " + OverallPossible.ToString());
 }