Esempio n. 1
0
        public async Task <PropertySyncFinalResponse> ExecuteSyncProcess(int siteId)
        {
            var response = new PropertySyncFinalResponse();

            var landlordsReponse = await UpdateLandlordInformationForSite(siteId);

            SyncLogger.WriteLog("Landlord information has been imported successfully");

            var propertiesResponse = await UpdatePropertiesInformationForSite(siteId);

            SyncLogger.WriteLog("Properties information has been imported successfully");

            var tenantsResponse = await UpdateTenantInformationForSite(siteId);

            SyncLogger.WriteLog("Tenant information has been imported successfully");


            response.SyncedTenants    = tenantsResponse;
            response.SyncedLandlords  = landlordsReponse;
            response.SyncedProperties = propertiesResponse;

            var itemsToSync = PropertySyncItemsResponse.MapAll(tenantsResponse, SyncEntityTypeEnum.Tenants);

            itemsToSync.AddRange(PropertySyncItemsResponse.MapAll(landlordsReponse, SyncEntityTypeEnum.Landlords));
            itemsToSync.AddRange(PropertySyncItemsResponse.MapAll(propertiesResponse, SyncEntityTypeEnum.Properties));

            response.Responses = itemsToSync;

            SyncLogger.WriteLog("Responses has been mapped correctly");

            return(response);
        }
        //WEB API URL :api/warehouse-sync/sync-properties/{siteId}
        public async Task <IHttpActionResult> SyncPProperties(int siteId)
        {
            var postedData = PPropertyResponse.BindJson(new StreamReader(System.Web.HttpContext.Current.Request.InputStream).ReadToEnd());

            var processedItems = await _warehouseSyncService.UpdatePropertiesInformationForSite(siteId, postedData.Properties);

            var result = PropertySyncItemsResponse.MapAll(processedItems, SyncEntityTypeEnum.Properties);

            return(Ok(result));
        }