/// <summary> /// Office Info view model. /// </summary> /// <param name="eventManager">Event manager</param> /// <param name="configurationService">Configuration service</param> /// <param name="dataServices">Data services</param> /// <param name="dialogService">Dialog services</param> /// <param name="container">Unity Manager</param> /// <param name="manager">Region Manager</param> /// <param name="requestController">Request controller</param> public OfficeInfoViewModel(IEventManager eventManager, IConfigurationService configurationService, IDataServices dataServices, IDialogService dialogService, IUnityContainer container, IRegionManager manager, IInteractionRequestController requestController) : base(eventManager, configurationService, dataServices, dialogService, manager, requestController) { _assistDataService = dataServices.GetAssistDataServices(); _officeDataService = dataServices.GetOfficeDataServices(); _newOfficeCommand = new DelegateCommand(OnNewOffice); _newOfficeSave = new DelegateCommand(OnSaveOffice); _provinciaDto = new System.Collections.ObjectModel.ObservableCollection <ProvinceViewObject>(); _openDays = new System.Collections.ObjectModel.ObservableCollection <DailyTime>(); _currentHolidays = new Dictionary <DateTime, HolidayViewObject>(); _currentPartOfDay = null; AssistMapper = _assistDataService.Mapper; AssistCommand = new DelegateCommand <object>(OnAssistCommand); ItemChangedCommand = new DelegateCommand <object>(OnChangedField); AssistExecuted += OfficeAssistResult; DataObject = new OfficeViewObject(); DateTime dt = DateTime.Now; ProvinciaDto = _provinciaDto; CurrentYear = dt.Year.ToString(); ViewModelUri = new Uri("karve://office/viewmodel?id=" + Guid.ToString()); TimePickerSaveCommand = new DelegateCommand <object>(OnPickerSaveCommand); TimePickerResetCommand = new DelegateCommand <object>(OnPickerResetCommand); SelectedDaysCommand = new DelegateCommand <object>(OnSelectedDaysCommand); PartOfDaySelection = new DelegateCommand <object>(OnPartOfDaySelection); EventManager.RegisterObserverSubsystem(MasterModuleConstants.OfficeSubSytemName, this); ActiveSubSystem(); }
public IOfficeData GetNewOfficeDo(string code) { IOfficeData data = new Office(); OfficeViewObject viewObject = new OfficeViewObject(); data.Value = viewObject; data.Valid = true; return(data); }
public async Task <bool> SaveAsync(IOfficeData clientData) { OfficeViewObject viewObject = clientData.Value; if (!clientData.Valid) { throw new DataLayerException("Trying to save invalid paramter"); } await Task.Delay(1000); return(true); }
public async Task <IOfficeData> GetAsyncOfficeDo(string clientIndentifier) { IOfficeData data = new Office(); OfficeViewObject viewObject = new OfficeViewObject(); data.Value = viewObject; data.Valid = true; await Task.Delay(1); if (string.IsNullOrEmpty(clientIndentifier)) { throw new DataLayerException("Exception"); } return(data); }
/// <summary> /// /// </summary> /// <param name="commissionAgent"></param> /// <returns></returns> public async Task <bool> DeleteOfficeAsyncDo(IOfficeData commissionAgent) { IOfficeData data = new Office(); OfficeViewObject viewObject = new OfficeViewObject(); data.Value = viewObject; data.Valid = true; if (string.IsNullOrEmpty(data.Value.Codigo)) { throw new DataLayerException("Exception"); } await Task.Delay(1000); return(true); }
/// <summary> /// Validate the DataPayload /// </summary> /// <param name="request">Request to be validated</param> /// <returns></returns> public override bool Validate(DataPayLoad req) { if (!req.HasDataObject) { return(true); } var dtos = new OfficeViewObject(); switch (req.DataObject) { case IOfficeData dataObject: dtos = dataObject.Value; break; case OfficeViewObject dto: dtos = dto; break; } return(!string.IsNullOrEmpty(dtos.Codigo)); }
public async Task Should_Load_An_Office_Correctly() { // arrange IOfficeDataServices officeDataServices = _dataServices.GetOfficeDataServices(); IEnumerable <OfficeSummaryViewObject> officeSummary = await officeDataServices.GetPagedSummaryDoAsync(1, 10); OfficeSummaryViewObject summaryViewObject = officeSummary.FirstOrDefault <OfficeSummaryViewObject>(); Assert.NotNull(summaryViewObject); // act IOfficeData officeData = await officeDataServices.GetAsyncOfficeDo(summaryViewObject.Code).ConfigureAwait(false); // assert Assert.IsTrue(officeData.Valid); OfficeViewObject viewObject = officeData.Value as OfficeViewObject; Assert.NotNull(viewObject); Assert.AreEqual(summaryViewObject.Code, officeData.Value.Codigo); Assert.Greater(viewObject.Province.Count(), 0); Assert.Greater(viewObject.HolidayDates.Count(), 0); }
/// <summary> /// Get a new office. /// </summary> /// <param name="code">Create a new dto for the office.</param> /// <returns>Returns a new office.</returns> public IOfficeData GetNewOfficeDo(string code) { var data = new OfficeViewObject { Codigo = code, IsNew = true }; var office = new Office { ClientZoneDto = new ObservableCollection <ZonaOfiViewObject>(), ContableDelegaDto = new ObservableCollection <DelegaContableViewObject>(), CountryDto = new ObservableCollection <CountryViewObject>(), CityDto = new ObservableCollection <CityViewObject>(), CurrenciesDto = new ObservableCollection <CurrenciesViewObject>(), ProvinciaDto = new ObservableCollection <ProvinceViewObject>(), ZoneDto = new ObservableCollection <ClientZoneViewObject>(), Value = data, Valid = true }; return(office); }
public async Task SaveHolidaysAsync(OfficeViewObject dto, IEnumerable <HolidayViewObject> holidaysDates) { await _saver.SaveHolidaysAsync(dto, holidaysDates).ConfigureAwait(false); }
public Task SaveHolidaysAsync(OfficeViewObject viewObject, IEnumerable <HolidayViewObject> holidaysDates) { throw new System.NotImplementedException(); }