Ejemplo n.º 1
0
        public async Task <Response> AddSubject(Course course, Subject subject)
        {
            Response response = new Response();

            try
            {
                ValidationResult validationResponse = await new SubjectValidator().ValidateAsync(subject);
                if (!validationResponse.IsValid)
                {
                    response.Success = false;
                    response.ErrorList.Add("Validation Error");
                    return(response);
                }
                response = await _repository.AddSubject(course, subject);

                return(response);
            }
            catch (Exception e)
            {
                StringBuilder sb = new StringBuilder();
                log.Error(sb.AppendLine(e.Message).AppendLine(e.StackTrace).ToString());
                response.Success = false;
                response.ErrorList.Add("Error while adding sybject to Course.");
                return(response);
            }
        }