public CrearPracticaResponse Ejecutar(CrearPracticaRequest request) { var admin = _unitOfWork.PracticaServiceRepository.FindFirstOrDefault(t => t.IdEstudiante == request.IdEstudiante); if (admin == null) { Practica newPractica = new Practica(request.IdEstudiante, request.IdDocente, request.IdEmpresa, request.Descripcion, request.Estado); var errors = newPractica.CanCrear(); if (errors.Any()) { return new CrearPracticaResponse() { Message = errors[0] } } ; _unitOfWork.PracticaServiceRepository.Add(newPractica); _unitOfWork.Commit(); return(new CrearPracticaResponse() { Message = $"Practica Creada Exitosamente" }); } else { return(new CrearPracticaResponse() { Message = $"Practica ya existe" }); } } }
public ActionResult PostEstudiante([FromBody] CrearPracticaRequest practica) { _service = new CrearPracticaService(_unitOfWork); var rta = _service.Ejecutar(practica); if (rta.isOk()) { return(Ok(rta.Message)); } return(BadRequest(rta.Message)); }