public ActionResult <Product> Get(string id) { var product = _productService.Get(id); if (product == null) { return(NotFound()); } if (product.VendorIds.Count > 0) { var tempList = new List <Vendor>(); foreach (var vendorId in product.VendorIds) { var vendor = _vendorService.Get(vendorId); if (vendor != null) { tempList.Add(vendor); } } product.Vendors = tempList; } return(product); }
public ActionResult getVendor(string id) { Vendor Vendor = _vendorService.Get(id); if (Vendor != null) { Vendor.Pass = null; return(Ok(Vendor)); } else { return(NotFound("Vendor Not Found")); } }
public async void Get_null_record() { var mock = new ServiceMockFacade <IVendorRepository>(); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <Vendor>(null)); var service = new VendorService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.VendorModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLVendorMapperMock, mock.DALMapperMockFactory.DALVendorMapperMock, mock.BOLMapperMockFactory.BOLProductVendorMapperMock, mock.DALMapperMockFactory.DALProductVendorMapperMock, mock.BOLMapperMockFactory.BOLPurchaseOrderHeaderMapperMock, mock.DALMapperMockFactory.DALPurchaseOrderHeaderMapperMock); ApiVendorResponseModel response = await service.Get(default(int)); response.Should().BeNull(); mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>())); }
public async Task <ActionResult <Vendor> > LoginVendorAsync(Vendor vendor) { var Vendor = _vendorService.Get(vendor.Username); var response = Vendor != null && vendor.Pass == Vendor.Pass ? "Okay" : "NotOkay"; if (response == "Okay") { Console.WriteLine("OK"); var responseString = await "http://auth.pcoin.life/create" .PostJsonAsync(new { _id = Vendor._id, Username = Vendor.Username, Type = "Vendor" }) .ReceiveString(); return(Ok(responseString)); } else { Console.WriteLine("Not okay"); return(Unauthorized()); } }
public async Task <IActionResult> Get(int id) { try { var vendor = await vendorServ.Get(id); if (vendor == null) { return(NotFound()); } else { return(Ok(vendor)); } } catch (Exception ex) { Console.Error.WriteLine(ex.Message); return(StatusCode(500)); } }
public ActionResult <List <Vendor> > Get() => _vendorService.Get();
public Vendor Get(int id) { return(_vendorService.Get(id)); }