Ejemplo n.º 1
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);
            DateTime               dateOfTheLastService = doneServices.Count > 0? doneServices.OrderBy(a => a.LastModificationDate).FirstOrDefault().LastModificationDate:user.CreationDate;

            return(new UserInfoViewModel
            {
                Email = user.Email,
                Age = user.Age,
                Country = user.Country,
                CreationDate = user.CreationDate,
                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.Select(a => a.UserWork).ToList(),
                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,
                CompetitionBalance = balance.CompetitionBalance,
                PointsBalance = user.PointsBalance,
                UserSpecialCode = user.UserSpecialCode,
                UserName = user.UserName,
                VerifiedUser = user.verifiedInterpreter,
                ServiceProviderPoints = user.ServiceProviderPoints,
                dateOfLastService = dateOfTheLastService,
                rank = user.rank
            });
        }
Ejemplo n.º 2
0
        public ServiceViewModel getMappingv2(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);

            speed = speed < 1 ? 1 : speed;
            double            avg         = UserHelperLibrary.ServiceProviderAvgServices(helper.findUser(service.ServiceProviderId), services.Count);
            AccountController accountCont = new AccountController();
            ServiceViewModel  result      = new ServiceViewModel();

            result.Country                = service.Country;
            result.CreationDate           = service.CreationDate;
            result.Creator                = service.Creator;
            result.Description            = service.Description;
            result.CreatorId              = service.CreatorId;
            result.Id                     = service.id;
            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.ServicePathId          = service.ServicePathId;
            result.ServiceProvider        = service.ServiceProvider;
            result.ServiceProviderId      = service.ServiceProviderId;
            result.Status                 = service.Status;
            result.UserWork               = service.UserWork;
            result.UserWorkId             = service.UserWorkId;
            result.ServicePath            = service.ServicePath;
            result.ServiceProviderNewDate = service.ServiceProviderNewDate;

            result.ServiceProviderSpeed       = speed;
            result.ServiceProviderAvgServices = avg == 0 ? 1 : avg;

            return(result);
        }
Ejemplo n.º 3
0
        public List <CompetitionResult> getAvg(List <ApplicationUser> users, DateTime startDate, bool tempResult)
        {
            List <CompetitionResult> result = new List <CompetitionResult>();

            foreach (var user in users)
            {
                List <Service>    services      = helper.getUserServices(user.Id, startDate);
                List <Service>    activeSerives = helper.getServicesFiltered(services, CoreController.ServiceStatus.Active.ToString());
                List <Service>    doneServices  = helper.getServicesFiltered(services, CoreController.ServiceStatus.Done.ToString());
                double            avg           = UserHelperLibrary.ServiceProviderAvgServices(services.Count, startDate);
                CompetitionResult temp          = new CompetitionResult
                {
                    ServiceProviderId      = user.Id,
                    NumberOfActiveServices = activeSerives.Count(),
                    NumberOfDoneServices   = doneServices.Count(),
                    AvgServicesInOneDay    = avg == 0 ? 1 : avg,
                    LastModificationDate   = DateTime.Now,
                    CreationDate           = DateTime.Now,
                    //TotalBalance = balance.TransferedBalance,
                    //AvailableBalance = balance.DoneBalance,
                    //SuspendedBalance = balance.SuspendedBalance,
                };
                if (tempResult)
                {
                    temp.ServiceProvider = user;
                }
                result.Add(temp);
            }
            result = result.OrderByDescending(a => a.AvgServicesInOneDay).ToList();
            int j = 1;

            foreach (var item in result)
            {
                item.rank = j;
                j++;
            }
            return(result);
        }
Ejemplo n.º 4
0
        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);

            speed = speed < 1 ? 1 : speed;
            double            avg         = UserHelperLibrary.ServiceProviderAvgServices(helper.findUser(service.ServiceProviderId), services.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 ", "");
            result.ServiceProviderNewDate = service.ServiceProviderNewDate;

            result.ServiceProviderSpeed       = speed;
            result.ServiceProviderAvgServices = avg == 0 ? 1 : avg;

            return(result);
        }