/// <summary> /// Delete Country /// </summary> /// <param name="sheetId"></param> /// <returns></returns> public async Task <ActionResult> DeleteSheet(int sheetId) { JsonReturnData data = new JsonReturnData(); if (sheetId > 0) { string param = $"{nameof(sheetId)}={sheetId}"; SheetResultData result = await WebApiClient.DeleteAsync <SheetResultData>(Constant.WebApiControllerOffices, Constant.WebApiRemoveSheet, param); if (result == null) { data.ErrorMessage = SharedResources.ServerError; data.OperationSuccess = false; } else if (!result.OperationSuccess && result.Errors != null && result.Errors.Count > 0) { data.ErrorMessage = result.Errors.First(); data.OperationSuccess = false; } else if (result.OperationSuccess) { data.SuccessMessage = UserResources.Ok; data.OperationSuccess = true; } } else { data.ErrorMessage = UserResources.RequiredUserId; data.OperationSuccess = false; } return(new OmsJsonResult(data)); }
/// <summary> /// Get the sheete of the country . /// </summary> /// <returns></returns> private async Task <List <SheetViewData> > GetSheetsList(int countryId) { SheetRequestData findSheetRequestData = new SheetRequestData { SheetDto = new SheetItemData { CountryId = countryId }, FindSheetDto = FindSheetItemData.CountryId }; SheetResultData sheetResultData = await WebApiClient.PostFormJsonAsync <SheetRequestData, SheetResultData>(Constant.WebApiControllerOffices, Constant.WebApiFindSheets, findSheetRequestData); List <SheetViewData> sheetsList = new List <SheetViewData>(); if (sheetResultData != null && sheetResultData.OperationSuccess && sheetResultData.SheetDtoList != null) { foreach (var sheetDto in sheetResultData.SheetDtoList) { SheetViewData sheet = new SheetViewData { TranslationsList = new List <SheetTranslationItemData>(), Sheet = sheetDto }; sheet.TranslationsList = await GetSheetTranslations(sheetDto.SheetId); sheetsList.Add(sheet); } } return(sheetsList); }
public async Task <OmsJsonResult> UpdateSheet(SheetFormData sheetFormData) { JsonReturnData data = new JsonReturnData(); if (ModelState.IsValid) { SheetRequestData request = sheetFormData.ToRequestData(); SheetResultData result = await WebApiClient.PostFormJsonAsync <SheetRequestData, SheetResultData>(Constant.WebApiControllerOffices, Constant.WebApiUpdateSheet, request); if (result != null && result.OperationSuccess) { SheetTranslationRequestData translationRequest = new SheetTranslationRequestData { SheetTranslationDtoList = sheetFormData.TranslationsList.ToItemDataList() }; SheetTranslationResultData sheetTranslationResultData = await WebApiClient.PostFormJsonAsync <SheetTranslationRequestData, SheetTranslationResultData>(Constant.WebApiControllerOffices, Constant.WebApiUpdateSheetTranslationRange, translationRequest); if (sheetTranslationResultData == null) { data.ErrorMessage = SharedResources.ServerError; data.OperationSuccess = false; } else if (sheetTranslationResultData.Errors != null && (!sheetTranslationResultData.OperationSuccess || sheetTranslationResultData.Errors != null || sheetTranslationResultData.Errors.Count > 0)) { data.ErrorMessage = sheetTranslationResultData.Errors.FirstOrDefault(); data.OperationSuccess = false; } else if (sheetTranslationResultData.OperationSuccess) { data.SuccessMessage = UserResources.Ok; data.OperationSuccess = true; } } else if (result == null) { data.ErrorMessage = SharedResources.ServerError; data.OperationSuccess = false; } else if (!result.OperationSuccess && result.Errors != null && result.Errors.Count > 0) { data.ErrorMessage = result.Errors.First(); data.OperationSuccess = false; } else if (result.OperationSuccess) { data.SuccessMessage = UserResources.Ok; data.OperationSuccess = true; } } else { data = new JsonReturnData { ErrorMessage = CountryResources.RequiredFields, OperationSuccess = false }; } return(new OmsJsonResult(data)); }