public IActionResult Index(PagingParams pagingParams) { try { PostalServices PostalServices = new PostalServices(); objResponse = PostalServices.GetAllKabupaten(pagingParams); Response.Headers.Add("X-Pagination", objResponse.GetHeader().ToJson()); var response = new PostalModelOutput { IsSuccess = true, Code = 200, Message = "Success", Data = objResponse.List.Select(m => ToPostalInfo(m)).ToList(), Pagination = GetLinks(objResponse, "GetOpenKabupaten") }; return(Ok(response)); } catch (Exception ex) { _logger.Error(ex.Message.ToString()); var response = new PostalModelOutput { IsSuccess = false, Code = 422, Message = ex.Message.ToString(), }; return(Ok(response)); } }
public IActionResult Index(PagingParams pagingParams, string province, string kabupaten, string kelurahan) { try { #region "IF PARAM" if (province == null) { province = ""; } else { province = province.ToUpper(); } if (kabupaten == null) { kabupaten = ""; } else { kabupaten = kabupaten.ToUpper(); } if (kelurahan == null) { kelurahan = ""; } else { kelurahan = kelurahan.ToUpper(); } #endregion PostalServices PostalServices = new PostalServices(); objResponse = PostalServices.GetFilterThreeParam(pagingParams, province, kabupaten, kelurahan); Response.Headers.Add("X-Pagination", objResponse.GetHeader().ToJson()); var response = new PostalModelOutput { IsSuccess = true, Code = 200, Message = "Success", Data = objResponse.List.Select(m => ToPostalInfo(m)).ToList(), Pagination = GetLinks(objResponse, "GetOpenPostal") }; return(Ok(response)); } catch (Exception ex) { _logger.Error(ex.Message.ToString()); var response = new PostalModelOutput { IsSuccess = false, Code = 422, Message = ex.Message.ToString(), }; return(Ok(response)); } }
static void Main(string[] args) { PostalServices client1 = new PostalServices(); client1.Add(new DHL()); client1.SetData("Jose", "Esa del ese del aquel", DateTime.Now, "Mexico", "USA", DateTime.Today); client1.Measurement(); PostalServices client2 = new PostalServices(); client2.Add(new Fedex()); client2.SetData("Mario", "Esa del ese del aquel", DateTime.Now, "Mexico", "USA", DateTime.Today); client2.Measurement(); PostalServices client3 = new PostalServices(); client3.Add(new MEX()); client3.SetData("Pedro", "Esa del ese del aquel", DateTime.Now, "Mexico", "USA", DateTime.Today); client3.Notify(); client3.Add(new DHL()); client3.SetData("Pedro", "Esa del ese del aquel", DateTime.Now, "USA", "mexico", DateTime.Today); client3.Notify(); Console.ReadKey(); }