Exemple #1
0
        public Response <string> AddNewTask(AddTaskRequest request)
        {
            try
            {
                int affectedRows = _tasksRepository.AddNewTask(new Task
                {
                    Title          = request.Title,
                    Description    = request.Description,
                    ExpirationDate = request.ExpirationDate,
                    Type           = request.Type,
                    CreateDate     = DateTime.Now,
                    Status         = request.Status,
                    User           = _usersRepository.GetAllUsers(u => u.Hash == request.UserHash).FirstOrDefault()
                });

                return(affectedRows == 1
                    ? Response <string> .Succeeded("Dodano nowy task dla użytkownika " + request.UserHash)
                    : Response <string> .Failed());
            }
            catch (Exception ex)
            {
                _logger.LogCritical(ex.ToString());
                return(Response <string> .Failed());
            }
        }