Esempio n. 1
0
        public async Task <IActionResult> Post([FromBody] UserTaskType userTaskType)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(Constants.ServerMessage.BAD_REQUEST));
                }

                return(Ok(new { data = await repository.SaveUserTaskType(userTaskType) }));
            }
            catch (Exception ex)
            {
                logger.LogError(ex);
                return(StatusCode(500, Constants.ServerMessage.INTERNAL_SERVER_ERROR));
            }
        }
Esempio n. 2
0
        public async Task <UserTaskType> SaveUserTaskType(UserTaskType userTaskType)
        {
            if (userTaskType == null)
            {
                throw new ArgumentNullException(nameof(userTaskType));
            }

            if (userTaskType.Id <= 0)
            {
                userTaskType = new UserTaskType {
                    Name = userTaskType.Name
                };
                await repository.UserTaskType.AddAsync(userTaskType);
            }
            else
            {
                repository.UserTaskType.Update(userTaskType);
            }

            await repository.SaveChangesAsync();

            return(userTaskType);
        }
Esempio n. 3
0
 public UserTask(User user, UserTaskType type)
 {
     Type   = type;
     User   = user;
     Status = UserTaskStatus.Open;
 }