public async Task <ExcecutorDTO> AddExcecutor(ExcecutorDTO user) { var task = await taskRepo.FindByIdAsync(user.TaskId); TaskHistory history = new TaskHistory(); history.DateUpdated = DateTime.Now; history.UpdatedByUser = task.Customer; history.StartTaskStatus = await statusRepo.FindByIdAsync((int)task.TaskStatusId); task.ExecutorId = user.ExcecutorId; task.UpdatedById = task.CustomerId; task.DateUpdated = DateTime.Now; var status = (await statusRepo.GetWithIncludeAsync(s => s.Type == "In progress")).FirstOrDefault(); task.TaskStatusId = status.Id; history.FinalTaskStatus = await statusRepo.FindByIdAsync(status.Id); await taskRepo.UpdateAsync(task); await historyRepo.CreateAsync(history); return(user); }
public async System.Threading.Tasks.Task DeleteTask(int id) { var task = await taskRepo.FindByIdAsync(id); var comment = await commentRepo.GetAsync(c => c.TaskId == task.Id); var history = await historyRepo.GetAsync(h => h.Task.Id == task.Id); foreach (var c in comment) { await commentRepo.RemoveAsync(c); } foreach (var h in history) { await historyRepo.RemoveAsync(h); } await taskRepo.RemoveAsync(task); }
public async Task <IEnumerable <CommentDTO> > AddComment(CommentDTO comment) { comment.Date = DateTime.Now.ToString(); comment.UserName = (await userRepo.FindByIdAsync(comment.UserId)).Name; var myComment = mapper.Map <CommentDTO, Comment>(comment); await commentRepo.CreateAsync(myComment); var result = await GetComments(comment.TaskId); return(result); }
public async Task <Ratings> RateUser(int UserId, int RateByUser, int Mark, int UserStatusId) { var rating = new Ratings(); rating.UserId = UserId; rating.RateByUser = RateByUser; rating.Mark = Mark; rating.UserStatusId = UserStatusId; await ratingRepo.CreateAsync(rating); var countUsers = (await ratingRepo.GetWithIncludeAsync(x => x.UserId == UserId)).Count(); var rat = (await ratingRepo.GetWithIncludeAsync(x => x.UserId == UserId)).Sum(y => y.Mark) / countUsers; User user = await userRepo.FindByIdAsync(UserId); user.Rating = (int)rat; await userRepo.UpdateAsync(user); return(rating); }
public async Task <IEnumerable <TaskDTO> > DragAndDropTaskByCustomer(int taskId, int customerId, string secondStatus) { //зміна статусу таску var result = (await taskRepo.FindByIdAsync(taskId)); if ((await statusRepo.FindByIdAsync((int)result.TaskStatusId)).Type == "In progress") { result.ExecutorId = null; } var newStatus = (await statusRepo.GetWithIncludeAsync(s => s.Type == secondStatus)).FirstOrDefault(); result.TaskStatusId = newStatus.Id; await taskRepo.UpdateAsync(result); //повернення зміненого масиву створених тасків замовником var dtos = await GetCreatedTaskByUser(customerId); return(dtos); }
public async Task <User> UpdateUser(int id, UserInformation value) { var result = db.Users.SingleOrDefault(b => b.Id == id); if (result != null) { result.Name = value.Name; result.Birth_Date = value.Birth_Date; result.Email = value.Email; result.Sur_Name = value.Sur_Name; result.Phone_Number = value.Phone_Number; result.Login = value.Login; if (value.UserRoleName != null) { result.UserRoleId = (await rolesRepo.GetAsync(r => r.Type == value.UserRoleName)).FirstOrDefault().Id; } db.SaveChanges(); } return(await userRepo.FindByIdAsync(id)); }
public async System.Threading.Tasks.Task DeleteComment(int id) { var comment = await commentRepo.FindByIdAsync(id); await commentRepo.RemoveAsync(comment); }