예제 #1
0
        public ActionResult CreateReview(ExecutionReviewModel model)
        {
            if (model.Rating == null)
            {
                return(RedirectToAction("ViewHomeTasks", "Task"));
            }

            _unitOfWork.Tasks.AddExecutionReview(model);

            return(RedirectToAction("ViewHomeTasks", "Task"));
        }
예제 #2
0
        public ActionResult ExecutionReview(int taskId)
        {
            TaskModel task = _unitOfWork.Tasks.GetEntityById(taskId);

            ViewBag.Task = task;

            ExecutionReviewModel model = new ExecutionReviewModel();

            model.TaskId   = task.Id;
            model.Executor = task.Executive;

            return(View());
        }
예제 #3
0
        public void AddExecutionReview(ExecutionReviewModel model)
        {
            ExecutionReview review = new ExecutionReview();
            Task            task   = ctx.Tasks.First(t => t.Id == model.TaskId);

            review.TaskId     = model.TaskId;
            review.Task       = task;
            review.ExecutorId = task.ExecutiveId;
            review.Executor   = task.Executive;

            review.Rating = model.Rating;
            review.Review = model.Review;

            float?sum    = ctx.Reviews.Where(r => r.ExecutorId == review.ExecutorId).Sum(r => r.Rating);
            int   length = ctx.Reviews.Count(r => r.ExecutorId == review.ExecutorId) + 1;

            review.Executor.Rating = (float)(Math.Round((((sum == null ? 0 : sum.Value) + review.Rating.Value) / length), 2));

            ctx.Reviews.Add(review);
            ctx.SaveChanges();
        }