示例#1
0
        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);
        }
示例#2
0
        public async Task <UserAccountDTO> ConfirmEmail(string confirmCode)
        {
            var user = (await userRepo.GetAsync(u => u.ConfirmCode == confirmCode)).FirstOrDefault();

            if (user == null)
            {
                return(null);
            }

            user.EmailConfirmed = true;
            await userRepo.UpdateAsync(user);

            return(_mapper.Map <User, UserAccountDTO>(user));
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }