public void Handle() { try { DataModel.Meeting meeting = _uow.MeetingRepository.Get(_query.MandatorUIDs, _query.MeetingUID); if (meeting == null) { throw new DataException("No Entity found to UID : " + _query.MeetingUID); } if (!_query.MandatorUIDs.Intersect(meeting.MandatorUIDs).Any()) { throw new UnauthorizedAccessException("Meeting from another mandator"); } _uow.MeetingRepository.Delete(_query.MandatorUIDs, _query.MeetingUID); _uow.Commit(); } catch (UnauthorizedAccessException) { throw new UnauthorizedAccessException("Not Authorized to Delete the Entity"); } catch (DataException e) { throw new DataException("Internal Server Error during Saving Changes", e); } catch (Exception) { throw new Exception("Internal Server Error during Saving Changes"); } }
public Guid Handle() { try { DataModel.Meeting meeting = AutoMapper.Mapper.Map <DataModel.Meeting>(_query.MeetingDetailDomainModel); if (meeting == null) { throw new DataException("Could not Map MeetingDetailDomainModel to Meeting"); } //DynamicValidationService<DataModel.Meeting> validationService = new DynamicValidationService<DataModel.Meeting>(new UnityContainer()); //if (!validationService.Validate(meeting)) //{ // throw new DataException("Entity is Invalid"); //} if (_query.MandatorUIDs.Intersect(meeting.MandatorUIDs).Any()) { Guid meetingUid = Guid.NewGuid(); meeting.UID = meetingUid; _uow.MeetingRepository.Insert(_query.MandatorUIDs, meeting); _uow.Commit(); return(meeting.UID); } throw new UnauthorizedAccessException("Meeting from another mandator"); } catch (UnauthorizedAccessException) { throw new UnauthorizedAccessException("Not Authorized to Create the Entity"); } catch (InvalidOperationException) { throw new InvalidOperationException("Internal Server Error thrown during create process"); } catch (DataException e) { throw new DataException("Internal Server Error", e); } catch (Exception e) { throw new Exception("Internal Server Error", e); } }