コード例 #1
0
        public IEvent SpawnEvent(Card card, Guid squadId, int minute, Models.Match match)
        {
            var oppositionsDefenceRating = RatingHelper.CurrentRating(PositionalArea.DEF, match.GetOppositionSquad(squadId), match.Events);
            var shootersRating           = RatingHelper.CurrentRating(card.Id, match.GetSquad(squadId));

            var shotOnTargetChance = (int)Math.Round(oppositionsDefenceRating + shootersRating * Constants.SHOOTER_AGAINST_DEFENDERS_MODIFIER);

            var randomNumber = _randomnessProvider.Next(0, shotOnTargetChance);

            if (randomNumber <= shootersRating * Constants.SHOOTER_AGAINST_DEFENDERS_MODIFIER)
            {
                var gkRating = RatingHelper.CurrentRating(PositionalArea.GK, match.GetOppositionSquad(squadId), match.Events);

                var goalChanceAccum = (int)Math.Round(gkRating + shootersRating * Constants.SHOOTER_AGAINST_GK_MODIFIER);

                var goalRandomNumber = _randomnessProvider.Next(0, goalChanceAccum);
                if (goalRandomNumber <= shootersRating * Constants.SHOOTER_AGAINST_GK_MODIFIER)
                {
                    return(new Goal(minute, card.Id, squadId));
                }
                return(new ShotOnTarget(minute, card.Id, squadId));
            }

            return(new ShotOffTarget(minute, card.Id, squadId));
        }
コード例 #2
0
 /// <summary>
 /// Calculates and sets total rating
 /// </summary>
 /// <param name="postModelList">Post</param>
 private static void CalculateTotalRating(List <PostModel> postModelList)
 {
     foreach (var post in postModelList)
     {
         post.TotalRating = RatingHelper.CalculateRating(post.Ratings);
     }
 }
コード例 #3
0
        public List <ProductRatingResultSet> UpdateProductRating(int productId, int rating, string userName)
        {
            var         curUserId   = 0;
            UserService userService = new UserService();
            var         currentUser = ClaimsPrincipal.Current.Identity.Name;


            if (!string.IsNullOrEmpty(currentUser))
            {
                var user = userService.GetUser(currentUser);
                if (user != null)
                {
                    curUserId = user.UserId;
                }

                if (user != null && userName.ToLower() == user.Username.ToLower())
                {
                    //1,5 hardcoded for now.
                    var query  = RatingHelper.InsertProductRatingQuery(productId, rating, curUserId, 1, 5);
                    var update = _unitOfWork.ExecuteCommand(query, new SqlParameter("@productId", productId));

                    var getproductRatingQuery = RatingHelper.GetProductRating(productId);
                    return(_unitOfWork.ExecuteQuery <ProductRatingResultSet>(getproductRatingQuery));
                }
            }
            return(null);
        }
コード例 #4
0
        private decimal?GetSellerRating(int branchId)
        {
            var query = RatingHelper.GetSellerRating(branchId);
            var branchRatingResultSet = _unitOfWork.ExecuteQuery <BranchRatingResultSet>(query);

            if (branchRatingResultSet.Count > 0)
            {
                return(CalculateStarRating(branchRatingResultSet));
            }
            return(null);
        }
コード例 #5
0
            public Builder GetAllRatingsFromDB()
            {
                foreach (var data in this.datas)
                {
                    if (!string.IsNullOrEmpty(data))
                    {
                        ListRating.Add(RatingHelper.GetDataRatingFromString(data));
                    }
                }

                return(this);
            }
コード例 #6
0
        /// <summary>
        ///   Process Selected Option
        /// </summary>
        private void ProcessSelection()
        {
            switch (Selection)
            {
            case 1:
                PrintRating(RatingHelper.Get(SortBy.NAME_ASC));
                break;

            case 2:
                PrintRating(RatingHelper.Get(SortBy.NAME_DESC));
                break;

            case 3:
                PrintRating(RatingHelper.Get(SortBy.BEST_DESC));
                break;

            case 4:
                PrintRating(RatingHelper.Get(SortBy.WORST_DESC));
                break;

            case 5:
                SubMenu();
                break;

            case 6:
                GoBackToMainMenu();
                break;

            case 7:
                PrintRating(RatingHelper.Get(SortBy.THE_BEST));
                break;

            case 8:
                PrintRating(RatingHelper.Get(SortBy.IV_STARS_UP));
                break;

            case 9:
                PrintRating(RatingHelper.Get(SortBy.III_STARS_UP));
                break;

            case 10:
                PrintRating(RatingHelper.Get(SortBy.THE_WORST));
                break;

            case 11:
                PrintRating(RatingHelper.Get(SortBy.UNRATED));
                break;

            default:
                MainMenu(Name);
                break;
            }
        }
コード例 #7
0
ファイル: WordsQuery.cs プロジェクト: AndreyShp/StudyFun
        public List <PronunciationForUser> GetTranslations(UserLanguages userLanguages, string query, WordType wordType)
        {
            long sourceLanguageId              = userLanguages.From.Id;
            long translationLanguageId         = userLanguages.To.Id;
            var  parsedType                    = (int)wordType;
            List <PronunciationForUser> result = Adapter.ReadByContext(c => {
                var wordsWithTranslationsQuery = (from w1 in c.Word
                                                  join wt in c.WordTranslation on w1.Id equals wt.WordId1
                                                  join w2 in c.Word on wt.WordId2 equals w2.Id
                                                  where ((w1.Text == query || w2.Text == query)
                                                         &&
                                                         ((w1.Type & parsedType) == parsedType &&
                                                          (w2.Type & parsedType) == parsedType) &&
                                                         ((w1.LanguageId == sourceLanguageId &&
                                                           w2.LanguageId == translationLanguageId)
                                                          ||
                                                          (w1.LanguageId == translationLanguageId &&
                                                           w2.LanguageId == sourceLanguageId)))
                                                  select new { wt, w1, w2 });
                var wordsWithTranslations = wordsWithTranslationsQuery.ToList();

                HashSet <string> uniqueTranslations = new HashSet <string>();
                var wordsByIds = new Dictionary <long, List <Tuple <int, PronunciationForUser> > >();
                foreach (var wordWithTranslation in wordsWithTranslations)
                {
                    Word translation = wordWithTranslation.w1.LanguageId == sourceLanguageId
                                           ? wordWithTranslation.w2
                                           : wordWithTranslation.w1;

                    if (!uniqueTranslations.Add(translation.Text))
                    {
                        //такое слово уже есть - дублирование не нужно
                        continue;
                    }

                    //TODO: сортировать на стороне БД, как в GroupWordsQuery???
                    int rating = RatingHelper.GetRating(wordWithTranslation.wt.Rating);
                    List <Tuple <int, PronunciationForUser> > translations;
                    if (!wordsByIds.TryGetValue(translation.Id, out translations))
                    {
                        translations = new List <Tuple <int, PronunciationForUser> >();
                        wordsByIds.Add(translation.Id, translations);
                    }
                    translations.Add(new Tuple <int, PronunciationForUser>(rating, new PronunciationForUser(translation)));
                }
                return
                (wordsByIds.Values.SelectMany(e => e).OrderByDescending(e => e.Item1).Select(e => e.Item2).ToList());
            });

            return(result);
        }
コード例 #8
0
        private List <CorporationDTO> FilterCorporationsByRating(List <CorporationDTO> corporations, double wantedRating)
        {
            var filteredCorporations = new List <CorporationDTO>();

            foreach (var corporation in corporations)
            {
                var avgRating = RatingHelper.CountAverageRating(corporation.RatingCount, corporation.SumRating);
                if (avgRating.HasValue && avgRating >= wantedRating)
                {
                    filteredCorporations.Add(corporation);
                }
            }

            return(filteredCorporations);
        }
コード例 #9
0
        private List <FreelancerDTO> FilterFreelancersByRating(List <FreelancerDTO> freelancers, double wantedRating)
        {
            var filteredFreelancers = new List <FreelancerDTO>();

            foreach (var freelancer in freelancers)
            {
                var avgRating = RatingHelper.CountAverageRating(freelancer.RatingCount, freelancer.SumRating);
                if (avgRating.HasValue && avgRating >= wantedRating)
                {
                    filteredFreelancers.Add(freelancer);
                }
            }

            return(filteredFreelancers);
        }
コード例 #10
0
        private FreelancerListViewModel InitializeFreelancerListViewModel(QueryResultDTO <FreelancerDTO, FreelancerFilterDTO> result)
        {
            var finalList = result.PagedResult();

            foreach (FreelancerDTO freelancer in finalList)
            {
                freelancer.SumRating = RatingHelper.CountAverageRating(freelancer.RatingCount, freelancer.SumRating);
            }

            return(new FreelancerListViewModel
            {
                Freelancers = new List <FreelancerDTO>(finalList),
                Filter = result.Filter,
                CurrentPageIndex = result.RequestedPageNumber.HasValue ? (int)result.RequestedPageNumber : 1,
                PageCount = (int)Math.Ceiling(result.TotalItemsCount / (double)result.PageSize)
            });
        }
コード例 #11
0
        private CorporationListViewModel InitializeCorporationListViewModel(QueryResultDTO <CorporationDTO, CorporationFilterDTO> result)
        {
            var finalList = result.PagedResult();

            foreach (CorporationDTO corporation in finalList)
            {
                corporation.SumRating = RatingHelper.CountAverageRating(corporation.RatingCount, corporation.SumRating);
            }

            return(new CorporationListViewModel
            {
                Corporations = new List <CorporationDTO>(finalList),
                Filter = result.Filter,
                CurrentPageIndex = result.RequestedPageNumber.HasValue ? (int)result.RequestedPageNumber : 1,
                PageCount = (int)Math.Ceiling(result.TotalItemsCount / (double)result.PageSize)
            });
        }
コード例 #12
0
        /// <summary>
        /// Gets post with user and rating
        /// </summary>
        /// <param name="id">Post Id</param>
        /// <param name="userEmail">Current user email</param>
        /// <returns>RichPostModel</returns>
        public RichPostModel GetRichPost(int id, string userEmail)
        {
            var post = _postRepository.Get(p => p.Id == id).FirstOrDefault();

            if (post == null)
            {
                throw new PostNotFoundException();
            }
            var richPost = _richPostMapper.ToBlModel(post);

            richPost.TotalRating = RatingHelper.CalculateRating(post.Ratings);
            if (userEmail != null)
            {
                var currentUserId = _userRepository.GetByEmail(userEmail).Id;
                richPost.SelectedRating = GetSelectedRating(currentUserId, post.Ratings);
            }
            return(richPost);
        }
コード例 #13
0
        /// <summary>
        ///   Generic Rating Printer
        /// </summary>
        /// <param name="data">Sorted/Filtered Data</param>
        private void PrintRating(IEnumerable <RestaurantProfiles> data)
        {
            Console.WriteLine("======================================================================");
            for (var i = 0; i < data.Count(); i++)
            {
                var item   = data.ElementAt(i);
                var number = (i + 1).ToString().PadLeft(5, '0');
                var name   = item.RestaurantName.PadRight(46, ' ');
                Console.Write($"{number} {name} Rating: ");
                RatingHelper.DrawStars(item.OverallRating.GetValueOrDefault());
                Console.Write(Environment.NewLine);
            }

            Console.WriteLine("======================================================================");
            Console.WriteLine("Press any key to return to the main menu ...");
            Console.ReadLine();
            // if current value is greater than 6 means is a sub menu, then go back to sub menu root.
            Selection = Selection > 6 ? 5 : -1;
            ProcessSelection();
        }
コード例 #14
0
        // GET: Corporations/Details/5
        public async Task <ActionResult> Details(int id)
        {
            var model = await UserFacade.GetCorporationAsync(id);

            var idOffers = await OfferFacade.ListOffersAsync(new OfferFilterDTO { SearchedAuthorsIds = new int[] { id } });

            model.Offers = new List <OfferDTO>(idOffers.Items);

            var appliedOffers = await OfferFacade.ListOffersAsync(new OfferFilterDTO { SearchedAppliersIds = new int[] { id } });

            model.AppliedToOffers = new List <OfferDTO>(appliedOffers.Items);

            var ratings = await RatingFacade.ListRatingsAsync(new RatingFilterDTO { SearchedRatedUsersId = new int[] { id } });

            model.Ratings = await RatingHelper.MergeRatingsCreators(UserFacade, ratings.Items.ToList());

            model.SumRating = RatingHelper.CountAverageRating(model.RatingCount, model.SumRating);

            return(View("CorporationDetailView", model));
        }
コード例 #15
0
        public HttpResponseMessage GetTopMovieGroupLengths()
        {
            HttpResponseMessage response = new HttpResponseMessage();

            try
            {
                ArrayList topList = RatingHelper.GetTopMovieGroup();
                response.Content    = new StringContent(JsonObjectConverter.ObjectToJson(topList));
                response.StatusCode = HttpStatusCode.OK;

                return(response);
            }
            catch (Exception e)
            {
                response.Content    = new StringContent(e.Message + '\n' + e.StackTrace);
                response.StatusCode = HttpStatusCode.NotFound;

                return(response);
            }
        }
コード例 #16
0
        public HttpResponseMessage GetLimit()
        {
            HttpResponseMessage response = new HttpResponseMessage();

            try
            {
                ArrayList ratingList = RatingHelper.GetLimitRating();
                response.Content    = new StringContent(JsonObjectConverter.ObjectToJson(ratingList));
                response.StatusCode = HttpStatusCode.OK;

                return(response);
            }
            catch (Exception e)
            {
                response.Content    = new StringContent(e.StackTrace);
                response.StatusCode = HttpStatusCode.NotFound;

                return(response);
            }
        }
コード例 #17
0
        // GET: FreelancerController/Details/5
        public async Task <ActionResult> Details(int id)
        {
            var model = await UserFacade.GetFreelancerAsync(id);

            var user = await UserFacade.GetUserAsync(id);

            var offers = await OfferFacade.ListOffersAsync(new OfferFilterDTO { SearchedAuthorsIds = new int[] { id } });

            model.Offers = new List <OfferDTO>(offers.Items);

            var appliedOffers = await OfferFacade.ListOffersAsync(new OfferFilterDTO { SearchedAppliersIds = new int[] { id } });

            model.AppliedToOffers = new List <OfferDTO>(appliedOffers.Items);

            var ratings = await RatingFacade.ListRatingsAsync(new RatingFilterDTO { SearchedRatedUsersId = new int[] { id } });

            model.Ratings = await RatingHelper.MergeRatingsCreators(UserFacade, ratings.Items.ToList());

            model.SumRating = RatingHelper.CountAverageRating(model.RatingCount, model.SumRating);

            return(View("FreelancerDetailView", InitializeFreelancerDetailViewModel(model, user.UserName)));
        }
コード例 #18
0
        public void GetAllRating()
        {
            var schedule = new List <int>()
            {
            };
            var connection    = new DBConnection();
            var eval          = new Evaluator();
            var scheduleQuery = $"select GeneratedPlanId from GeneratedPlan where GeneratedPlanId > 600";
            var schedules     = connection.ExecuteToDT(scheduleQuery);

            foreach (DataRow schedulesRow in schedules.Rows)
            {
                schedule.Add((int)schedulesRow["GeneratedPlanId"]);
            }


            foreach (int scheduleId in schedule)
            {
                var parameterQuery = $"select ParameterSetId from GeneratedPlan where GeneratedPlanId={scheduleId}";
                var parameterId    = (int)connection.ExecuteToDT(parameterQuery).Rows[0]["ParameterSetId"];

                var parameterSetQuery = $"select ParameterSet.MajorID, SchoolID, TimePeriod, MaxNumberOfQuarters, NumberCoreCoursesPerQuarter, CreditsPerQuarter, SummerPreference, DepartmentId from ParameterSet join Major on ParameterSet.MajorID = Major.MajorID" +
                                        $" join TimePreference on TimePreference.TimePreferenceID = ParameterSet.TimePreferenceID" +
                                        $" where ParameterSetId = {parameterId}";
                var parameterSetResult = connection.ExecuteToDT(parameterSetQuery);

                var parameters = Preferences.ConvertFromDatabase(parameterSetResult, parameterId);

                var query = "select CourseNumber, QuarterID, YearID, Course.CourseId, Course.DepartmentID from StudyPlan" +
                            " join course on Course.CourseID = StudyPlan.CourseID" +
                            $" where GeneratedPlanID = {scheduleId}";

                var results = connection.ExecuteToDT(query);
                var model   = ScheduleModel.ConvertFromDatabase(results, scheduleId, parameters);
                var rating  = eval.evalaute(model);

                RatingHelper.UpdateWeakLabelScore(scheduleId, rating);
            }
        }
コード例 #19
0
 public RatingSystemScreen(Action goBackToMainMenu)
 {
     Options = new[]
     {
         "\t[1] List Restaurants Alphabetically",
         "\t[2] List Restaurants in Reverse Alphabetical",
         "\t[3] Sort Restaurants From Best to Worst",
         "\t[4] Sort Restaurants From Worst to Best",
         "\t[5] Show Only X and Up",
         "\r\n"
     };
     SubOptions = new[]
     {
         "\r\n",
         "\t[1] Show the best",
         "\t[2] Show 4 Stars and Up",
         "\t[3] Show 3 Stars and Up",
         "\t[4] Show the Worst",
         "\t[5] Show Unrated"
     };
     RatingHelper     = new RatingHelper();
     GoBackToMainMenu = goBackToMainMenu;
 }
コード例 #20
0
        public new async Task <ActionResult> Profile()
        {
            var user = await userFacade.GetUserAccordingToUsernameAsync(User.Identity.Name);

            var idOffers = await offerFacade.ListOffersAsync(new OfferFilterDTO { SearchedAuthorsIds = new int[] { user.Id } });

            var idAppliedOffers = await offerFacade.ListOffersAsync(new OfferFilterDTO { SearchedAppliersIds = new int[] { user.Id } });

            var idRatings = await ratingFacade.ListRatingsAsync(new RatingFilterDTO { SearchedRatedUsersId = new int[] { user.Id } });

            if (user.UserRole == "Freelancer")
            {
                var freelancer = await userFacade.GetFreelancerAsync(user.Id);

                freelancer.Offers          = new List <OfferDTO>(idOffers.Items);
                freelancer.AppliedToOffers = new List <OfferDTO>(idAppliedOffers.Items);
                freelancer.Ratings         = await RatingHelper.MergeRatingsCreators(userFacade, idRatings.Items.ToList());

                freelancer.SumRating = RatingHelper.CountAverageRating(freelancer.RatingCount, freelancer.SumRating);

                return(View("Users/FreelancerDetailView", ToProfileModel(freelancer, user.UserName)));
            }
            else if (user.UserRole == "Corporation")
            {
                var corporation = await userFacade.GetCorporationAsync(user.Id);

                corporation.Offers          = new List <OfferDTO>(idOffers.Items);
                corporation.AppliedToOffers = new List <OfferDTO>(idAppliedOffers.Items);
                corporation.Ratings         = await RatingHelper.MergeRatingsCreators(userFacade, idRatings.Items.ToList());

                corporation.SumRating = RatingHelper.CountAverageRating(corporation.RatingCount, corporation.SumRating);

                return(View("Users/CorporationDetailView", corporation));
            }

            return(RedirectToAction("Index", "Home"));
        }
コード例 #21
0
        public List <BranchRatingResultSet> GetBranchRating(int branchId)
        {
            var query = RatingHelper.GetSellerRating(branchId);

            return(_unitOfWork.ExecuteQuery <BranchRatingResultSet>(query));
        }
コード例 #22
0
        /// <summary>
        /// Calculates user's rating
        /// </summary>
        /// <param name="userId">User Id</param>
        /// <returns>Rating</returns>
        private int CalculateRating(int userId)
        {
            var ratings = _ratingRepository.Get(r => r.Post.UserId == userId);

            return(RatingHelper.CalculateRating(ratings));
        }
コード例 #23
0
        public List <ProductRatingResultSet> GetProductRating(int productId)
        {
            var query = RatingHelper.GetProductRating(productId);

            return(_unitOfWork.ExecuteQuery <ProductRatingResultSet>(query));
        }
コード例 #24
0
        /// <summary>
        /// Gets total rating for post
        /// </summary>
        /// <param name="postId">Post Id</param>
        /// <returns>Total Rating</returns>
        private int GetTotalRating(int postId)
        {
            var ratings = _ratingRepository.Get(r => r.PostId == postId);

            return(RatingHelper.CalculateRating(ratings));
        }
コード例 #25
0
        protected LeadAssignmentVM GetLeadAssignmentViewModel(LeadAssignment item)
        {
            var itemVM = new LeadAssignmentVM();

            itemVM.Id     = item.Id;
            itemVM.LeadId = item.LeadId;

            if (item.Lead != null)
            {
                itemVM.LeadDetails = item.Lead.Details;

                if (item.Lead.LeadType != null)
                {
                    itemVM.LeadTypeName  = item.Lead.LeadType.Name;
                    itemVM.LeadTypeImage = ImageHelper.PATH_CLIENT_LEAD_TYPE + item.Lead.LeadType.Image;
                }

                if (item.Lead.Customer != null)
                {
                    itemVM.CustomerId     = item.Lead.Customer.Id;
                    itemVM.CustomerUnique = String.Format("{0} ({1})", item.Lead.Customer.ContactName, item.Lead.Customer.EMail);

                    itemVM.CustomerName          = item.Lead.Customer.ContactName;
                    itemVM.CustomerBusinessName  = item.Lead.Customer.BusinessName;
                    itemVM.CustomerEMail         = item.Lead.Customer.EMail;
                    itemVM.CustomerContactNumber = item.Lead.Customer.ContactNumber;
                    itemVM.CustomerStreetAddress = item.Lead.Customer.Address.StreetAddress;
                    itemVM.CustomerSuburb        = item.Lead.Customer.Address.Suburb;
                    itemVM.CustomerState         = item.Lead.Customer.Address.State;
                    itemVM.CustomerPostCode      = item.Lead.Customer.Address.PostCode;
                    itemVM.CustomerAddress       = AddressHelper.MergeAddress(itemVM.CustomerStreetAddress, itemVM.CustomerSuburb, itemVM.CustomerState, itemVM.CustomerPostCode);

                    itemVM.CustomerDetails = String.Format("Business: <b>{0}</b><br>Tel: <b>{1}</b><br>Address: <b>{2}</b>", itemVM.CustomerBusinessName, itemVM.CustomerContactNumber, itemVM.CustomerAddress);
                }
            }

            itemVM.PartnerId   = item.PartnerBranch.Partner.Id;
            itemVM.PartnerName = item.PartnerBranch.Partner.Name;
            itemVM.PartnerLogo = ImageHelper.PATH_CLIENT_PARTNER + item.PartnerBranch.Partner.Logo;

            itemVM.PartnerBranchId            = item.PartnerBranch.Id;
            itemVM.PartnerBranchStreetAddress = item.PartnerBranch.Address.StreetAddress;
            itemVM.PartnerBranchSuburb        = item.PartnerBranch.Address.Suburb;
            itemVM.PartnerBranchState         = item.PartnerBranch.Address.State;
            itemVM.PartnerBranchPostCode      = item.PartnerBranch.Address.PostCode;
            itemVM.PartnerBranchAddress       = AddressHelper.MergeAddress(itemVM.PartnerBranchStreetAddress, itemVM.PartnerBranchSuburb, itemVM.PartnerBranchState, itemVM.PartnerBranchPostCode);

            // Current status
            var currentStatus = item.LeadAssignmentStates.Where(w => w.StateId != nameof(EnumState.S0)).OrderByDescending(o => o.ActionTimestamp).FirstOrDefault();

            itemVM.StatusId   = currentStatus.State.Id;
            itemVM.StatusName = currentStatus.State.Name;
            itemVM.StatusTag  = StatusHelper.GetHtmlBadge(currentStatus.State.Id, currentStatus.State.Name);
            itemVM.RatingTag  = RatingHelper.GetHtmlRatingTag(item.Comment, item.CommentedBy, item.CommentedOn);

            if (string.IsNullOrEmpty(_userRoleName))
            {
                _userRoleName = _accountManager.GetRoleAsync(_accountManager.GetUserAsync(User.Identity.Name).Result).Result;
            }

            // Actions of current status
            var actions = currentStatus.State.StateActions.Where(w => this.IsActionAllowed(w.Action.Id, _userRoleName)).Select(s => new ActionLeadAssignmentVM
            {
                Id               = s.ActionId,
                LeadId           = itemVM.LeadId,
                PartnerBranchId  = itemVM.PartnerBranchId,
                LeadAssignmentId = itemVM.Id,
                CustomerEmail    = itemVM.CustomerEMail,
                PartnerEmails    = _salesRepo.GetByPartner(itemVM.PartnerId).Select(person => person.EMail).ToList(),
                ControllerName   = s.Action.ControllerName,
                ActionName       = s.Action.ActionName,
                ActionTarget     = s.Action.ActionTarget,
                RequestType      = s.Action.RequestType,
                DisplayName      = s.Action.DisplayName,
                Icon             = s.Action.Icon,
                NextStateId      = s.Action.NextStateId,
                Rating           = new Rating()
                {
                    Rate = item.Rate, Comment = item.Comment ?? string.Empty, CommentedOn = item.CommentedOn, CommentedBy = item.CommentedBy
                }
            }).ToList();

            itemVM.Actions = actions;

            // CreatedWhen
            var firstSssignedOn = item.LeadAssignmentStates.OrderBy(o => o.ActionTimestamp).FirstOrDefault();

            itemVM.AssignedOn = DateHelper.ConvertFromUtc(firstSssignedOn.ActionTimestamp).Date;

            // History
            var histories = item.LeadAssignmentStates
                            .OrderByDescending(o => o.ActionTimestamp)
                            //.Where(w => w.StateId != currentStatus.StateId) // *show all
                            .Select(s => HistoryHelper.GetHtmlHistoryLine(DateHelper.ConvertFromUtc(s.ActionTimestamp), s.Action.ToLower(), s.Actor));

            itemVM.History = HistoryHelper.GetHtmlHistoryTag(histories.ToList());

            return(itemVM);
        }