public static Domain.Assessment.Assessment MapToAssessmentDto(CreateAssessmentRequest assessmentRequestModel) { var assessmentDto = new Domain.Assessment.Assessment { AssessmentDate = assessmentRequestModel.AssessmentDate, RecurrenceTypeId = assessmentRequestModel.FrequencyId, AssessmentScopeId = assessmentRequestModel.ScopeId, AssessmentTypeId = assessmentRequestModel.AssessmentTypeId, Reference = assessmentRequestModel.Reference, Title = assessmentRequestModel.Title, PublishedDate = assessmentRequestModel.PublishedDate, PublishedBy = assessmentRequestModel.PublishedByUserId, IsArchived = false, IsDeleted = false, IsSuperseded = false, AssessorUserId = 1, Id = assessmentRequestModel.Id, DataId = assessmentRequestModel.DataId }; if (assessmentDto.Id == default(int)) { assessmentDto.AddedDate = DateTime.UtcNow; assessmentDto.AddedBy = 1; } else { assessmentDto.ModifiedBy = 1; assessmentDto.ModifiedDate = DateTime.UtcNow; } return(assessmentDto); }
public async Task <SaveResponseDto> Insert(Domain.Assessment.Assessment entity) { var id = _assessmentRepository.GetLast().Id; entity.DataId = DataIdGenerationService.GenerateDataId(id, "AM"); var response = await _assessmentRepository.AddAsync(entity); return(new SaveResponseDto { SavedDataId = entity.DataId, SavedEntityId = entity.Id, SaveSuccessful = response != null }); }
public async Task <SaveResponseDto> Update(Domain.Assessment.Assessment entity) { if (entity.DataId == null) { var id = _assessmentRepository.GetLast().Id; entity.DataId = DataIdGenerationService.GenerateDataId(id, "AM"); } var response = await _assessmentRepository.UpdateAsync(entity, entity.Id); return(new SaveResponseDto { SavedDataId = entity.DataId, SavedEntityId = entity.Id, SaveSuccessful = response != null, ErrorMessage = response == null ? string.Empty : "update failed" }); }
public static CreateAssessmentRequest MapToAssessmentModel(Domain.Assessment.Assessment assessmentDto) { return(new CreateAssessmentRequest { AssessmentDate = assessmentDto.AssessmentDate, FrequencyId = assessmentDto.RecurrenceTypeId ?? 0, ScopeId = assessmentDto.AssessmentScopeId, AssessmentTypeId = assessmentDto.AssessmentTypeId ?? 0, Reference = assessmentDto.Reference, Title = assessmentDto.Title, PublishedDate = assessmentDto.PublishedDate, PublishedByUserId = assessmentDto.PublishedBy ?? default(int), ModifiedDate = DateTime.UtcNow, IsSuperseded = false, DataId = assessmentDto.DataId, Published = assessmentDto.PublishedBy.HasValue && assessmentDto.PublishedDate.HasValue, Id = assessmentDto.Id }); }