public bool AddTaskForUser(int userId, string description, IResponseModel model)
        {
            string message = GetMessageForModel(userId, description);

            if (message != null)
            {
                model.AddAttribute("action_result", message);
                return(false);
            }

            return(true);
        }
 public bool AddTaskForUser(int userId, string description, IResponseModel model)
 {
     try
     {
         _taskService.AddTaskForUser(userId, new UserTask(description));
     }
     catch (AddUserTaskException e)
     {
         model.AddAttribute("action_result", DataProvider.GetErrorMessage(e));
         return(false);
     }
     return(true);
 }
示例#3
0
        public bool AddTaskForUser(int userId, string description, IResponseModel model)
        {
            try
            {
                GetMessageForModel(userId, description);
            }
            catch (Exception e)
            {
                model.AddAttribute("action_result", e.Message);
                return(false);
            }

            return(true);
        }
示例#4
0
        public bool AddTaskForUser(int userId, string description, IResponseModel model)
        {
            var task = new UserTask(description);

            try
            {
                taskService.AddTaskForUser(userId, task);
                return(true);
            }
            catch (ArgumentOutOfRangeException)
            {
                model?.AddAttribute(ModelErrorKey, "Invalid userId");
            }
            catch (UserNotFoundException)
            {
                model?.AddAttribute(ModelErrorKey, "User not found");
            }
            catch (TaskAlreadyExistsException)
            {
                model?.AddAttribute(ModelErrorKey, "The task already exists");
            }

            return(false);
        }
示例#5
0
        /// <summary>
        /// Method for adding task attribute for user.
        /// </summary>
        /// <param name="userId">User Id.</param>
        /// <param name="description">Description.</param>
        /// <param name="model">Respond model.</param>
        /// <returns>True if task is added.</returns>
        public bool AddTaskForUser(int userId, string description, IResponseModel model)
        {
            if (model is null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            string message = this.GetMessageForModel(userId, description);

            if (message != null)
            {
                model.AddAttribute("action_result", message);
                return(false);
            }

            return(true);
        }