public ActionResponse Save(DocumentTypeDto obj, Guid?userId = null) { try { var valResult = new DocumentTypeValidator().Validate(obj); if (valResult.IsValid) { var response = _documentTypeRepository.Save(obj); return(response); } else { var valErrors = valResult.Errors.Select(e => e.ErrorMessage).ToArray(); return(ActionResponse.Failure(valErrors)); } } catch (Exception ex) { return(ActionResponse.Failure(ex.Message)); } }
public DocumentTypesService(IUnitOfWork unitOfWork) { this.unitOfWork = unitOfWork; mapper = new MapperService(); documentTypeValidator = new DocumentTypeValidator(); }