Esempio n. 1
0
        public void CrearEstudiante(CrearResponsableRequest request, string expected)
        {
            _service = new CrearResponsableService(_unitOfWork);
            var response = _service.Ejecutar(request);

            Assert.AreEqual(expected, response.Message);
        }
Esempio n. 2
0
        public CrearResponsableResponse Ejecutar(CrearResponsableRequest request)
        {
            var responsable = _unitOfWork.ResponsableServiceRepository.FindFirstOrDefault(t => t.IdeResponsable == request.IdeResponsable);

            if (responsable == null)
            {
                Dominio.Responsable newResponsable = new Dominio.Responsable(request.IdeResponsable, request.NomResponsable, request.FecNacimiento, request.LugNacimiento,
                                                                             request.LugExpedicion, request.TipDocumento, request.CelResponsable, request.ProfResponsable, request.OcuResponsable, request.EntResponsable, request.CelEmpresa,
                                                                             request.TipoResponsable, request.Correo, request.Acudiente, request.IdUsuario);

                IReadOnlyList <string> errors = newResponsable.CanCrear(newResponsable);
                if (errors.Any())
                {
                    string listaErrors = "Errores:";
                    foreach (var item in errors)
                    {
                        listaErrors += item.ToString();
                    }
                    return(new CrearResponsableResponse()
                    {
                        Message = listaErrors
                    });
                }
                else
                {
                    _unitOfWork.ResponsableServiceRepository.Add(newResponsable);
                    _unitOfWork.Commit();
                    return(new CrearResponsableResponse()
                    {
                        Message = $"Responsable Creado Exitosamente"
                    });
                }
            }
            else
            {
                return(new CrearResponsableResponse()
                {
                    Message = $"Responsable ya existe"
                });
            }
        }