public double GetUserSpeed(String UserId)
        {
            List <Service> services      = helper.getUserServices(UserId);
            List <Service> activeSerives = helper.getServicesFiltered(services, CoreController.ServiceStatus.Active.ToString());
            List <Service> doneServices  = helper.getServicesFiltered(services, CoreController.ServiceStatus.Done.ToString());
            double         speed         = UserHelperLibrary.ServiceProviderSpeed(helper.findUser(UserId), doneServices.Count);

            return(speed);
        }
        public ServiceViewModel getMapping(Service service)
        {
            List <Service> allService = db.Services.Where(a => a.ServiceProviderId.Equals(service.ServiceProviderId) &&
                                                          a.ServicePathId.Equals(service.ServicePathId) &&
                                                          a.Status.Equals(CoreController.ServiceStatus.Active.ToString())).ToList();

            List <Service> services      = helper.getUserServices(service.ServiceProviderId);
            List <Service> activeSerives = helper.getServicesFiltered(services, CoreController.ServiceStatus.Active.ToString());
            List <Service> doneServices  = helper.getServicesFiltered(services, CoreController.ServiceStatus.Done.ToString());
            double         speed         = UserHelperLibrary.ServiceProviderSpeed(helper.findUser(service.ServiceProviderId), doneServices.Count);

            AccountController accountCont = new AccountController();
            ServiceViewModel  result      = new ServiceViewModel();

            result.Comments                    = service.Comments;
            result.Country                     = service.Country;
            result.CreationDate                = service.CreationDate;
            result.Creator                     = service.Creator;
            result.Description                 = service.Description;
            result.CreatorId                   = service.CreatorId;
            result.DidYouExorcism              = service.DidYouExorcism;
            result.DreamDate                   = service.DreamDate;
            result.Explanation                 = service.Explanation;
            result.ExplanationDate             = service.ExplanationDate;
            result.HaveYouPrayedBeforeTheDream = service.HaveYouPrayedBeforeTheDream;
            result.id = service.id;
            result.IsThereWakefulness   = service.IsThereWakefulness;
            result.JobStatus            = service.JobStatus;
            result.KidsStatus           = service.KidsStatus;
            result.LastModificationDate = service.LastModificationDate;
            result.Modifier             = service.Modifier;
            result.ModifierId           = service.ModifierId;
            result.Name                = service.Name;
            result.numberOfLikes       = service.numberOfLikes;
            result.numberOfViews       = service.numberOfViews;
            result.PrivateService      = service.PrivateService;
            result.PrivateServicePrice = service.PrivateServicePrice;
            result.PublicServiceAction = service.PublicServiceAction;
            result.RegligionStatus     = service.RegligionStatus;
            result.ServicePathId       = service.ServicePathId;
            result.ServiceProvider     = service.ServiceProvider;
            result.ServiceProviderId   = service.ServiceProviderId;
            result.Sex                      = service.Sex;
            result.SocialStatus             = service.SocialStatus;
            result.Status                   = service.Status;
            result.UserWork                 = service.UserWork;
            result.UserWorkId               = service.UserWorkId;
            result.ServicePath              = service.ServicePath;
            result.NumberOfAllPeopleWaiting = allService.Count > 0 ? allService.Count : 0;
            result.NumberOfRemainingPeople  = allService.Count > 0 ? allService.Where(a => a.CreationDate.CompareTo(service.CreationDate) < 0).Count() : 0;
            result.AvgWaitingTime           = UserHelperLibrary.getWaitingTimeMessage(Double.Parse(speed.ToString()),
                                                                                      Double.Parse(result.NumberOfRemainingPeople.ToString())).Replace("Your average waiting time is ", "");



            return(result);
        }
Beispiel #3
0
        public UserInfoViewModel getInfoMapping(ApplicationUser user)
        {
            List <Service>         services      = helper.getUserServices(user.Id);
            List <Service>         activeSerives = helper.getServicesFiltered(services, CoreController.ServiceStatus.Active.ToString());
            List <Service>         doneServices  = helper.getServicesFiltered(services, CoreController.ServiceStatus.Done.ToString());
            var                    userManager   = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(new ApplicationDbContext()));
            List <UserWorkBinding> userWork      = db.UserWorkBindings.Where(a => a.UserId.Equals(user.Id)).Include("UserWork").ToList();
            double                 speed         = UserHelperLibrary.ServiceProviderSpeed(helper.findUser(user.Id), doneServices.Count);
            double                 avg           = UserHelperLibrary.ServiceProviderAvgServices(helper.findUser(user.Id), services.Count);
            UserBalance            balance       = helper.getUserBalance(user);

            return(new UserInfoViewModel
            {
                Email = User.Identity.GetUserName(),
                Age = user.Age,
                Country = user.Country,
                JobDescription = user.JobDescription,
                JoiningDate = user.JoiningDate,
                Name = user.Name,
                MartialStatus = user.MartialStatus,
                PictureId = user.PictureId,
                Sex = user.Sex,
                Status = user.Status,
                Type = user.Type,
                phoneNumber = user.PhoneNumber,
                PersonalDescription = user.PersonalDescription,
                FireBaseId = user.FireBaseId,
                Id = user.Id,
                HasRegistered = user.verifiedInterpreter,
                UserWorks = userWork,
                NumberOfActiveServices = activeSerives.Count(),
                NumberOfDoneServices = doneServices.Count(),
                Speed = speed < 1?1:speed,
                AvgServicesInOneDay = avg == 0 ? 1 : avg,
                UserRoles = userManager.GetRoles(user.Id).ToList(),
                SocialStatus = user.SocialState,
                ImageUrl = user.imageUrl,
                SocialToken = user.SocialToken,
                TotalBalance = balance.TransferedBalance,
                AvailableBalance = balance.DoneBalance,
                SuspendedBalance = balance.SuspendedBalance
            });
        }