예제 #1
0
        public void ApproveAllTasks(string username, long gigrequestId)
        {
            var currentUser = _dbContext.Users.FirstOrDefault(x => x.UserName == username);
            IQueryable<Task> query = _dbContext.Task
                .Include("Order")
                .Include("Order.User")
                .Include("User")
                .Include("Asset")
                .Where(x => x.Order.User.UserName == username && x.TaskStatus == TaskStatus.InReview);
            if (gigrequestId != 0)
                query = query.Where(x => x.Order.Id == gigrequestId);

            foreach (var task in query)
            {
                task.TaskStatus = TaskStatus.Completed;
                task.Order.TasksInReview--;

                var review = new Review
                {
                    Author = currentUser,
                    User = task.User,
                    CreateDate = DateTime.Now,
                    Message = string.Empty,
                    Rate = 5,
                    ReviewMark = ReviewMark.Positive
                };
                _dbContext.Review.Add(review);
                _billingService.Transfer(currentUser, task.User, task.Order.Price);
            }
            _dbContext.SaveChanges();
        }
예제 #2
0
        public ActionResult WriteReview(WriteReviewModel model)
        {
            var user = _userRepository.GetById(model.UserId);
            var currentUser = _userRepository.GetByUsername(User.Identity.Name);
            Order order = null;
            if (model.GigId != 0)
                order = _ordersRepository.GetById(model.GigId);

            double rating = 0;
            double.TryParse(model.Rating.Replace(",", "."), NumberStyles.Any, CultureInfo.InvariantCulture,out rating);
            var review = new Review
            {
                CreateDate = DateTime.Now,
                Rate = rating,
                User = user,
                ReviewMark = model.ReviewMark,
                Author = currentUser,
                Message = model.Message,
                Order = order
            };
            _reviewRepository.Save(review);
            _userService.RebuildUserRating(user.Id);
            if(order!=null)
                _gigService.RebuildGigRating(order.Id);
            return RedirectToAction("View", new {id = user.Id});
        }
예제 #3
0
 public void Save(Review review)
 {
     _dbContext.Review.Add(review);
     _dbContext.SaveChanges();
 }