Esempio n. 1
0
 /// <summary>
 ///  This save/insert asynchronously an office.
 /// </summary>
 /// <param name="client">Office to save.</param>
 /// <returns>Returns true o false in case of saving office data.</returns>
 public async Task <bool> SaveAsync(IOfficeData client)
 {
     if (client.Valid)
     {
         return(await _saver.SaveAsync(client.Value).ConfigureAwait(false));
     }
     return(false);
 }
Esempio n. 2
0
        public async Task <bool> SaveAsync(IOfficeData clientData)
        {
            OfficeDtos dto = clientData.Value;

            if (!clientData.Valid)
            {
                throw new DataLayerException("Trying to save invalid paramter");
            }
            await Task.Delay(1000);

            return(true);
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="commissionAgent"></param>
        /// <returns></returns>
        public async Task <bool> DeleteOfficeAsyncDo(IOfficeData commissionAgent)
        {
            IOfficeData data = new Office();
            OfficeDtos  dto  = new OfficeDtos();

            data.Value = dto;
            data.Valid = true;
            if (string.IsNullOrEmpty(data.Value.Codigo))
            {
                throw new DataLayerException("Exception");
            }
            await Task.Delay(1000);

            return(true);
        }
        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);
        }
Esempio n. 5
0
        protected override async Task <DataPayLoad> HandleSaveOrUpdate(DataPayLoad payLoad)
        {
            Contract.Requires(payLoad != null, "The payload at company data shall be not null");
            Contract.Requires(payLoad.DataObject != null, "Payload shall have data object");
            if (payLoad.DataObject is OfficeViewObject dto)
            {
                IOfficeData data = _officeDataServices.GetNewOfficeDo(dto.Codigo);
                data.Value = dto;
                bool result = false;
                try
                {
                    result = await _officeDataServices.SaveAsync(data).ConfigureAwait(false);
                }
                catch (DataLayerException e)
                {
                    throw new DataLayerException("Error during saving", e);
                }


                // FIXME: where it is used current payload. shall enforce dry.
                if (result)
                {
                    payLoad.Sender      = ToolBarModule.NAME;
                    payLoad.PayloadType = DataPayLoad.Type.UpdateView;
                    // see if currentPayload make sense.
                    CurrentPayload = new DataPayLoad
                    {
                        PayloadType   = DataPayLoad.Type.UpdateView,
                        Sender        = ToolBarModule.NAME,
                        HasDataObject = true,
                        Subsystem     = payLoad.Subsystem,
                        DataObject    = data
                    };
                }
            }

            Contract.Ensures(payLoad != null);
            return(payLoad);
        }
Esempio n. 6
0
 /// <summary>
 ///  Delete asynchronously an office.
 /// </summary>
 /// <param name="office">Office Entity to delete</param>
 /// <returns>True o false in case we have an office to delete.</returns>
 public async Task <bool> DeleteOfficeAsyncDo(IOfficeData office)
 {
     return(await _deleter.DeleteAsync(office.Value).ConfigureAwait(false));
 }
Esempio n. 7
0
 public async Task <bool> DeleteAsync(IOfficeData booking)
 {
     return(await DeleteOfficeAsyncDo(booking).ConfigureAwait(false));
 }
Esempio n. 8
0
 public Task <bool> DeleteAsync(IOfficeData booking)
 {
     throw new System.NotImplementedException();
 }