public ActionResult <ProductModelViewModel> Get(Guid id) { var res = _bo.Read(id); if (res.Success) { if (res.Result == null) { return(NotFound()); } var pmvm = new ProductModelViewModel() { Id = res.Result.Id, Name = res.Result.Name, BarCode = res.Result.BarCode, Description = res.Result.Description, Price = res.Result.Price.ToString(), Amount = res.Result.Amount.ToString(), Measure = res.Result.Measure, BrandId = res.Result.BrandId, CategoryId = res.Result.CategoryId }; return(pmvm); } else { return(StatusCode((int)HttpStatusCode.InternalServerError)); } }
public void TestCreateAndReadProductModel() { ContextSeeder.Seed(); var braBo = new BrandBusinessObject(); var bra = braBo.ListNotDeleted().Result.First(); var catBo = new CategoryBusinessObject(); var cat = catBo.ListNotDeleted().Result.First(); var bo = new ProductModelBusinessObject(); var prodMod = new ProductModel("Vinho Branco", "506-1237-422", "", 4.24, 0.80, Measure.L, bra.Id, cat.Id); var resCreate = bo.Create(prodMod); var resGet = bo.Read(prodMod.Id); Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null); }