public GetSupplierResponse GetSupplierById(GetSupplierRequest request) { var bc = DependencyInjectionHelper.GetBusinessComponent <SupplierBusinessComponent>(); var supplier = bc.GetSupplierById(request.SupplierId); var response = new GetSupplierResponse(); response.Supplier = SupplierAdapter.SupplierToDTO(supplier); return(response); }
public GetSupplierResponse GetSupplierById(GetSupplierRequest request) { GetSupplierResponse response = new GetSupplierResponse(); SupplierBusinessComponent bc = DependencyInjectionHelper.GetSupplierBusinessComponent(); Supplier supplier = bc.GetSupplierById(request.Id); response.Supplier = SupplierAdapter.SupplierToDto(supplier); return(response); }
public JsonResult GetDetail(System.Int32 id) { SupplierDetailView vm = new SupplierDetailView(); GetSupplierRequest request = new GetSupplierRequest(); request.SupplierID = id; GetSupplierResponse response = _supplierService.GetSupplier(request); if (response.SupplierFound) { vm = response.Supplier.ConvertToSupplierDetailView(); } return(Json(vm, JsonRequestBehavior.AllowGet)); }
public SupplierDTO GetSupplierById(int id) { try { GetSupplierRequest request = new GetSupplierRequest(); request.Id = id; GetSupplierResponse response = Service.GetSupplierById(request); return(response.Supplier); } catch (Exception ex) { if (ExceptionPolicy.HandleException(ex, "PL Policy")) { throw; } return(new SupplierDTO()); } }
public GetSupplierResponse GetSupplier(GetSupplierRequest request) { GetSupplierResponse response = new GetSupplierResponse(); Supplier supplier = _supplierRepository .FindBy(request.SupplierID); if (supplier != null) { response.SupplierFound = true; response.Supplier = supplier.ConvertToSupplierView(); } else { response.SupplierFound = false; } return(response); }
public IHttpActionResult GetById(int id) { GetSupplierResponse response = new GetSupplierResponse(); try { List <Supplier> suppliers = supplierBL.GetSupplier(id); response.Suppliers = suppliers; response.Success = true; } catch (SupplierException ex) { response.ErrorCode = ex.Error; response.ErrorMessage = "Error. " + ex.Error.ToString(); response.Success = false; } catch (Exception ex) { response.ErrorMessage = "Error. " + ex.Message; response.Success = false; } return(Ok(response)); }
public void UpdateCurrentSupplier() { if (supplierView.SelectedId == -1) { supplierView.CurrentSupplier = new Supplier(); } else { HttpClient client = new HttpClient(); client.BaseAddress = new Uri(baseUrl); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Token.access_token); HttpResponseMessage response = client.GetAsync(string.Format("{0}?id={1}", getByIdAction, supplierView.SelectedId)).Result; if (response.IsSuccessStatusCode) { GetSupplierResponse getSupplierResponse = response.Content.ReadAsAsync <GetSupplierResponse>().Result; if (getSupplierResponse.Success) { PropertyCopier.CopyProperties(getSupplierResponse.Suppliers[0], supplierView.CurrentSupplier); supplierView.CurrentSupplier.RaiseUpdateProperties(); } } } }