Example #1
0
        public ActionResult Details(string id)
        {
            var customer = _customerService.FindCustomerProfile(id);

            if (customer == null)
            {
                return(View("Error"));
            }

            var customerModel = new CustomerDetailsViewModel()
            {
                Id                = customer.Id,
                FirstName         = customer.FirstName,
                LastName          = customer.LastName,
                ImagePath         = Convert.ToBase64String(customer.Image),
                UserName          = customer.UserName,
                RegistrationdDate = customer.RegistrationdDate,
                CountPublishJobs  = customer.CountPublishJobs,
                CountReviews      = customer.QualityOfWorks.Count(),
            };

            if (customer.QualityOfWorks.Count() > 0)
            {
                customerModel.AvarageReviewMark = (int)customer.QualityOfWorks.Select(p => (int)p).Average();
            }

            int    countFeedbacksForPer     = customerModel.CountReviews == 0 ? 1 : customerModel.CountReviews;
            double percentPositiveFeedBacks = (double)customer.QualityOfWorks.Count(p => (int)p >= 3) * 100 / countFeedbacksForPer;

            customerModel.PercentPositiveReviews = (int)Math.Round(percentPositiveFeedBacks);

            return(View(customerModel));
        }