public CaseDto EditCase(Guid caseId, ClientDto clientDto, CaseInformationDto caseInformationDto, NotesDto notesDto, CaseStatusDto caseStatusDto, List <CaseReferenceDto> caseReferenceDtos) { CaseDto caseDto = new CaseDto(); try { var caseList = this.CaseRepository.Find(c => c.Id == caseId); if (caseList.Count == 0) { return(null); } Case @case = caseList.First(); @case = this.CaseRepository.Update(@case); caseDto.Id = @case.Id; caseDto.CaseId = @case.CaseId; caseDto.ModifiedOn = @case.ModifiedOn; caseDto.CreatedOn = @case.CreatedOn; caseDto.Client = this.ClientBusinessLogic.EditClient(clientDto); caseDto.CaseInformation = this.CaseInformationBusinessLogic.EditCaseInformation(caseInformationDto); caseDto.CaseStatus = this.CaseStatusBusinessLogic.EditCaseStatus(caseStatusDto); caseDto.Notes = this.NotesBusinessLogic.EditNotes(notesDto); caseDto.References = this.CaseReferenceBusinessLogic.EditCaseReferences(caseReferenceDtos, caseId); return(caseDto); } catch (Exception exception) { throw exception; } }
public CaseInformationDto EditCaseInformation(CaseInformationDto caseInformationDto) { try { if (caseInformationDto == null) { return(null); } CaseInformation caseInformation = this.CaseInformationMapper.DtoToModel(caseInformationDto); caseInformation = this.CaseInformationRepository.Update(caseInformation); return(this.CaseInformationMapper.ModelToDto(caseInformation)); } catch (Exception exception) { throw exception; } }
public CaseInformationDto AddNewCaseInformation(CaseInformationDto caseInformationDto, Guid caseId) { try { if (caseInformationDto == null) { return(null); } CaseInformation caseInformation = CaseInformationMapper.DtoToModel(caseInformationDto); caseInformation.CaseId = caseId; caseInformation = this.CaseInformationRepository.Add(caseInformation); return(this.CaseInformationMapper.ModelToDto(caseInformation)); } catch (Exception exception) { throw exception; } }
public CaseDto AddNewCase(ClientDto clientDto, CaseInformationDto caseInformationDto, NotesDto notesDto, CaseStatusDto caseStatusDto, List <CaseReferenceDto> caseReferenceDtos) { try { CaseDto addedCaseDto = new CaseDto(); Case newCase = new Case(); Case addedCase = CaseRepository.Add(newCase); addedCaseDto.CaseId = addedCase.CaseId; addedCaseDto.Id = addedCase.Id; addedCaseDto.ModifiedOn = addedCase.ModifiedOn; addedCaseDto.CreatedOn = addedCase.CreatedOn; addedCaseDto.Client = ClientBusinessLogic.AddNewClient(clientDto, addedCase.Id); addedCaseDto.CaseInformation = CaseInformationBusinessLogic.AddNewCaseInformation(caseInformationDto, addedCase.Id); addedCaseDto.CaseStatus = CaseStatusBusinessLogic.AddNewCaseStatus(caseStatusDto, addedCase.Id); addedCaseDto.Notes = NotesBusinessLogic.AddNewNotes(notesDto, addedCase.Id); addedCaseDto.References = CaseReferenceBusinessLogic.AddNewCaseReferences(caseReferenceDtos, addedCase.Id); return(addedCaseDto); } catch (Exception exception) { throw exception; } }
public OperationResponse <CaseDto> Post(CreateCase request) { OperationResponse <CaseDto> operationResponse = new OperationResponse <CaseDto>(); ClientValidator clientValidator = new ClientValidator(); CaseInformationValidator caseInformationValidator = new CaseInformationValidator(); NotesValidator notesValidator = new NotesValidator(); CaseInformationDto caseInformation = request.CaseDto.CaseInformation; ClientDto client = request.CaseDto.Client; NotesDto notes = request.CaseDto.Notes; CaseStatusDto caseStatus = request.CaseDto.CaseStatus; List <CaseReferenceDto> references = request.CaseDto.References; List <string> errors = new List <string>(); ValidationResult validationResult = clientValidator.Validate(client); if (!validationResult.IsValid) { ; foreach (var error in validationResult.Errors) { errors.Add(error.ErrorMessage); } } validationResult = caseInformationValidator.Validate(caseInformation); if (!validationResult.IsValid) { foreach (var error in validationResult.Errors) { errors.Add(error.ErrorMessage); } } validationResult = notesValidator.Validate(notes); if (!validationResult.IsValid) { foreach (var error in validationResult.Errors) { errors.Add(error.ErrorMessage); } } if (errors.Count != 0) { operationResponse.OnError("Invalid input data", errors); return(operationResponse); } try { CaseDto caseDto = CaseBusinessLogic.AddNewCase(client, caseInformation, notes, caseStatus, references); operationResponse.OnSuccess(caseDto, "Added successfully"); return(operationResponse); } catch (Exception e) { Log.Error(e.Message); operationResponse.OnException(e.Message); return(operationResponse); } }
public OperationResponse <CaseDto> Put(EditCase request) { OperationResponse <CaseDto> operationResponse = new OperationResponse <CaseDto>(); ClientValidator clientValidator = new ClientValidator(); CaseInformationValidator caseInformationValidator = new CaseInformationValidator(); NotesValidator notesValidator = new NotesValidator(); CaseInformationDto caseInformation = request.CaseDto.CaseInformation; ClientDto client = request.CaseDto.Client; NotesDto notes = request.CaseDto.Notes; CaseStatusDto caseStatus = request.CaseDto.CaseStatus; List <CaseReferenceDto> references = request.CaseDto.References; ValidationResult validationResult = clientValidator.Validate(client); if (!validationResult.IsValid) { List <string> errors = new List <string>(); foreach (var error in validationResult.Errors) { errors.Add(error.ErrorMessage); } operationResponse.OnError("Invalid client data", errors); return(operationResponse); } validationResult = caseInformationValidator.Validate(caseInformation); if (!validationResult.IsValid) { List <string> errors = new List <string>(); foreach (var error in validationResult.Errors) { errors.Add(error.ErrorMessage); } operationResponse.OnError("Invalid case-information data", errors); return(operationResponse); } validationResult = notesValidator.Validate(notes); if (!validationResult.IsValid) { List <string> errors = new List <string>(); foreach (var error in validationResult.Errors) { errors.Add(error.ErrorMessage); } operationResponse.OnError("Invalid case-information data", errors); return(operationResponse); } try { CaseDto caseDto = this.CaseBusinessLogic.EditCase(client.CaseId, client, caseInformation, notes, caseStatus, references); operationResponse.OnSuccess(caseDto, "Saved successfully"); return(operationResponse); } catch (Exception e) { Log.Error(e.Message + " " + e.StackTrace); operationResponse.OnException(e.Message); return(operationResponse); } }