Esempio n. 1
0
        public async Task <CreateTaskResponse> Process(CreateTaskRequest request)
        {
            var task = new CssTask(request.Name);

            task.SetDueDate(request.DueDate);
            task.SetDescription(request.Description);
            task.SetScheduledDate(request.ScheduledDate);

            //we don't allow them to save invalid tasks.
            if (task.IsValid())
            {
                try
                {
                    await _repository.Save(task);

                    return(new CreateTaskResponse(true));
                }
                catch (Exception ex)
                {
                    //Oh crap errors, validations are handled by is valid.
                    _logger.LogError(ex, "Unable to create task.");
                    var errors = new Validations();
                    errors.AddError(ErrorCode.Unexpected, ex.Message);
                    return(new CreateTaskResponse(false, errors));
                }
            }
            return(new CreateTaskResponse(false, task.Errors));
        }
Esempio n. 2
0
        public void ValidDescription(string description)
        {
            var obj = new CssTask(TaskName);

            obj.SetDescription(description);

            Assert.True(obj.IsValid());
        }
Esempio n. 3
0
        public void CanSetDescription()
        {
            var obj = new CssTask(TaskName);

            obj.SetDescription(TaskDescription);

            Assert.True(obj.IsValid());
            Assert.Equal(TaskDescription, obj.Description);
        }