public void TestThatResolvingNotesWasPopulated() { AlarmFiredEditDto dto = new AlarmFiredEditDto(); dto.AlarmColor = Domain.ValueObjects.AlarmColor.Red; dto.AlarmId = _session.QueryOver <Alarm>().List().First().Id; dto.Fall = false; dto.FallNoResponse = false; dto.ParameterId = _session.QueryOver <Parameter>().List().First().Id; dto.ProcessInstanceId = _session.QueryOver <ProcessInstance>().List().First().Id; dto.ResolvingNotes = "test"; dto.Result = "Test risultato"; IAlarmFiredService service = new AlarmFiredService(_session); var oresult = service.CreateAlarmFired(dto); }
public OperationResult <Guid?> CreateAlarmFired(AlarmFiredEditDto dto) { //Validazione argomenti if (dto == null) { throw new ArgumentNullException(nameof(dto)); } //Dichiaro la lista di risultati di ritorno IList <ValidationResult> vResults = new List <ValidationResult>(); Alarm alarm = dto.AlarmId.HasValue ? _alarmRepository.Load(dto.AlarmId):null; //Definisco l'entità AlarmFired entity = new AlarmFired(); entity.IsActive = true; entity.Parameter = dto.ParameterId.HasValue ? _parameterRepository.Load(dto.ParameterId) : null; entity.ProcessInstance = dto.ProcessInstanceId.HasValue ? _processInstanceRepository.Load(dto.ProcessInstanceId) : null; entity.AlarmColor = dto.AlarmColor; entity.Result = dto.Result; entity.Alarm = dto.AlarmId.HasValue ? _alarmRepository.Load(dto.AlarmId) : null; entity.ResolvingNotes = alarm?.HelpMessage; entity.IsFall = !dto.Fall.HasValue ? false : dto.Fall; entity.IsFallNoResponse = !dto.FallNoResponse.HasValue? false: dto.FallNoResponse; entity.Latitude = dto.Latitude; entity.Longitude = dto.Longitude; entity.Patient = string.Format("{0} {1}", entity.ProcessInstance.Patient.Firstname, entity.ProcessInstance.Patient.Surname); entity.PatientFeedback = dto.PatientFeedback; entity.InsertUser = IdentityHelper.GetUsername(); //Eseguo la validazione logica vResults = ValidateEntity(entity); if (!vResults.Any()) { //Salvataggio su db _alarmFiredRepository.Save(entity); } //Ritorno i risultati return(new OperationResult <Guid?> { ReturnedValue = entity.Id, ValidationResults = vResults }); }
public IHttpActionResult TurnOff(AlarmFiredEditDto dto) { //Recupero l'entity var oResult = _alarmFiredService.TurnOff(dto); //Se ci sono stati errori, li notifico if (oResult.HasErrors()) { Log4NetConfig.ApplicationLog.Warn(string.Format("Errore durante la modifica di un allarme. id: {0}, parameterName: {1}, Errors: {2}", dto.Id, dto.ParameterId, oResult.GetValidationErrorsInline(" - "))); NHibernateHelper.SessionFactory.GetCurrentSession().Transaction.Rollback(); return(ResponseMessage(Request.CreateResponse(HttpStatusCode.BadRequest, oResult))); } //Ritorno i risultati return(ResponseMessage(Request.CreateResponse(HttpStatusCode.OK))); }
public OperationResult <Guid?> TurnOff(AlarmFiredEditDto dto) { //Validazione argomenti if (dto == null) { throw new ArgumentNullException(nameof(dto)); } if (!dto.Id.HasValue) { throw new ArgumentNullException(nameof(dto.Id)); } //Dichiaro la lista di risultati di ritorno IList <ValidationResult> vResults = new List <ValidationResult>(); //Definisco l'entità AlarmFired entity = _alarmFiredRepository.Load(dto.Id); entity.IsActive = false; entity.UpdateDate = DateTime.Now; entity.Feedback = dto.Feedback; if (!string.IsNullOrWhiteSpace(dto.Feedback)) { entity.FeedbackDate = DateTime.Now; entity.FeedbackBy = IdentityHelper.GetUsername(); } entity.InsertUser = IdentityHelper.GetUsername(); //Eseguo la validazione logica vResults = ValidateEntity(entity); if (!vResults.Any()) { //Salvataggio su db _alarmFiredRepository.Save(entity); } //Ritorno i risultati return(new OperationResult <Guid?> { ReturnedValue = entity.Id, ValidationResults = vResults }); }