示例#1
0
        public ActionResult Create(CreateCommentViewModel model)
        {
            var currentUser = userManager.GetUserAsync(HttpContext.User).Result.Id;

            if (ModelState.IsValid)
            {
                CommentDTO comment = new CommentDTO
                {
                    ExerciseId       = model.ExerciseId,
                    UserId           = currentUser,
                    UserName         = User.Identity.Name,
                    CommentText      = model.CommentText,
                    Rating           = model.Rating,
                    CreationDateTime = DateTime.Now
                };
                commentManager.Insert(comment);
                if (model.Rating != null)
                {
                    var    commentlist = commentManager.Get(g => g.ExerciseId == model.ExerciseId && g.Rating != 0).ToList();
                    double average     = 0;
                    foreach (var elem in commentlist)
                    {
                        if (elem.Rating != 0)
                        {
                            average += Convert.ToDouble(elem.Rating);
                        }
                    }

                    average = average / commentlist.Count;
                    exerciseManager.UpdateRating(model.ExerciseId, average);
                }
            }
            return(RedirectToAction("TaskView ", "ExerciseManagement", model.ExerciseId));
        }
示例#2
0
        public ActionResult AllUnseenComments()
        {
            List <CommentViewModel> commentListViewModel = new List <CommentViewModel>();
            var commentListView = commentManager.Get(c => c.IsReceiverSeen == false).Where(c => c.ReceiverEmployeeId == GetEmployeeId());

            foreach (var item in commentListView.ToList())
            {
                var cmnt = new CommentViewModel
                {
                    Id           = item.Id,
                    RequsitionId = item.RequsitionId,
                    Requsition   = _requisitionManager.GetById(item.RequsitionId),
                    EmployeeId   = item.EmployeeId,
                    Comments     = item.Comments,
                    //UserName = item.UserName,
                    CommentTime = item.CommentTime,
                    //IsReceiverSeen = item.IsReceiverSeen,
                    //ReceiverSeenTime = item.ReceiverSeenTime,
                    SenderEmployee = item.SenderEmployee,
                    //SenderEmployeeId = (int)item.SenderEmployeeId,
                    //ReceiverEmployee = item.ReceiverEmployee,
                    //ReceiverEmployeeId = (int)item.ReceiverEmployeeId
                };
                commentListViewModel.Add(cmnt);
            }
            //assignVm.CommentViewModels = commentListViewModel;
            return(View(commentListViewModel));
        }
示例#3
0
        public async Task <CommentDTO> Get(long id)
        {
            var comment = await commentManager.Get(id);

            if (comment == null)
            {
                return(null);
            }
            return(mapper.Map <CommentDTO>(comment));
        }
        public IActionResult TaskView(int id)
        {
            var task        = exerciseManager.GetById(id);
            var commentList = commentManager.Get(g => g.ExerciseId == id).ToList();

            return(View(new GetExerciseViewModel()
            {
                Id = id,
                Course = task.Course,
                CommentList = commentList,
                TaskName = task.TaskName,
                TaskTextField = task.TaskTextField,
                TaskBaseCodeField = task.TaskBaseCodeField
            }));
        }
示例#5
0
        public IActionResult UploadImage(int id, IFormFile image)
        {
            var comment = CommentManager.Get(id);

            if (comment == null)
            {
                return(NotFound());
            }
            if (comment.AccountId != User.Claims.FirstOrDefault(c => c.Type == "UserId").Value)
            {
                return(Unauthorized());
            }

            CommentManager.UploadImage(image, comment);
            return(NoContent());
        }
示例#6
0
 public IActionResult AddNewComment(int id, string author, string text)
 {
     if (!string.IsNullOrWhiteSpace(text) && text.Length > 0)
     {
         var commentId  = _cardRepository.AddNewComment(id, author, text);
         var newComment = _commentManager.Get(commentId);
         var date       = newComment.CreationDate.ToLocalTime().ToString();
         var authorName = newComment.Author;
         return(Json(new
         {
             success = true,
             id = commentId,
             date,
             name = authorName
         }));
     }
     else
     {
         return(Json(new { success = false }));
     }
 }
        //[Authorize]
        public ActionResult Dashboard()
        {
            var userEmployeeId = GetEmployeeId();

            ViewBag.UserEmployeeId = userEmployeeId;


            var requsition = _requisitionManager.GetAll().OrderByDescending(c => c.Id);


            GetMyRequisitionComments(userEmployeeId);

            var comments = commentManager.Get(c => c.IsReceiverSeen == false).Where(c => c.ReceiverEmployeeId == userEmployeeId);

            var commentsWithRequisition = from r in requsition
                                          join c in comments on r.Id equals c.RequsitionId
                                          select new
            {
                r.Id,
                r.Status,
                c.SenderEmployee,
                c.SenderEmployeeId,
                c.ReceiverEmployeeId,
                c.ReceiverSeenTime,
                c.IsReceiverSeen
            };
            List <CountCommentViewModel> commentsList = new List <CountCommentViewModel>();

            foreach (var item in commentsWithRequisition)
            {
                var comment = new CountCommentViewModel();
                comment.Id = item.Id;
                comment.ReceiverEmployeeId = item.ReceiverEmployeeId;
                comment.Status             = item.Status;
                commentsList.Add(comment);
            }
            if (commentsList.Count(c => c.Status == null) == 0)
            {
                ViewBag.NewRequisitionComments = 0;
            }
            if (commentsList.Count(c => c.Status == null) > 0)
            {
                ViewBag.NewRequisitionComments = commentsList.Count(c => c.Status == null);
            }
            if (commentsList.Count(c => c.Status == "Assign") == 0)
            {
                ViewBag.AssignRequisitionComments = 0;
            }
            if (commentsList.Count(c => c.Status == "Assign") > 0)
            {
                ViewBag.AssignRequisitionComments = commentsList.Count(c => c.Status == "Assign");
            }
            if (commentsList.Count(c => c.Status == "Hold") == 0)
            {
                ViewBag.HoldRequisitionComments = 0;
            }
            if (commentsList.Count(c => c.Status == "Hold") > 0)
            {
                ViewBag.HoldRequisitionComments = commentsList.Count(c => c.Status == "Hold");
            }

            return(View());
        }
示例#8
0
 public async Task <ApiResponse> Get(long id)
 => await _commentManager.Get(id);
示例#9
0
        public IActionResult Get(int excerciseId)
        {
            var json = commentManager.Get(c => c.ExerciseId == excerciseId).ToList();

            return(Ok(json));
        }
示例#10
0
        public List <CommentDTO> Get(int id)
        {
            var json = commentManager.Get(c => c.ExerciseId == id).ToList();

            return(json);
        }