/// <summary> /// Creates the keyed dto. /// </summary> /// <param name="key">The key to create.</param> /// <returns>A <see cref="Rem.Ria.PatientModule.Web.FrontDeskDashboard.SelfPaymentDto"/></returns> public SelfPaymentDto CreateKeyedDto(long key) { var selfPayment = _selfPaymentRepository.GetByKey(key); var dto = Mapper.Map <SelfPayment, SelfPaymentDto> (selfPayment); return(dto); }
/// <summary> /// Handles the specified request. /// </summary> /// <param name="request">The request.</param> /// <returns>A <see cref="Agatha.Common.Response"/></returns> public override Response Handle(SaveDtoRequest <SelfPaymentDto> request) { var requestDto = request.DataTransferObject; DomainEvent.Register <RuleViolationEvent>(failure => _validationFailureOccurred = true); LogicalTreeWalker.Walk <IDataTransferObject>(requestDto, dto => dto.ClearAllDataErrorInfo()); var response = CreateTypedResponse(); response.DataTransferObject = requestDto; if (requestDto.EditStatus == EditStatus.Create) { var selfPayment = CreateNew(requestDto); response.DataTransferObject = AutoMapper.Mapper.Map <SelfPayment, SelfPaymentDto> (selfPayment); } else if (requestDto.EditStatus == EditStatus.Delete) { var selfPayment = _selfPaymentRepository.GetByKey(requestDto.Key); if (selfPayment != null) { Delete(selfPayment); } response.DataTransferObject = requestDto; } var processSucceeded = !_validationFailureOccurred; if (processSucceeded) { Session.Flush(); Session.Clear(); } return(response); }