public void TestGetVendors() { Vendor Xiaomi = new Vendor { Name = "Xiaomi" }; vr.Create(Comanche); vr.Create(Xiaomi); List <Vendor> getvendors = vr.GetVendors(); int countvendors = getvendors.Count(); Assert.AreEqual(Comanche.Id, getvendors[countvendors - 2].Id, "Id should be equal"); }
public async Task <IActionResult> Create(Guid?vendorId, [FromBody] VendorModel vendor) { try { if (!vendorId.HasValue) { vendorId = Guid.NewGuid(); } var createdVendor = vendor.Clone(); createdVendor.CreationDate = DateTime.UtcNow; createdVendor.LastUpdate = null; createdVendor.Id = vendorId.Value; var savedVendor = await repository.Create(createdVendor, vendorId.Value.ToString()); return(CreatedAtAction(nameof(Get), new { vendorId = savedVendor.Id }, savedVendor)); } catch (Exception ex) { // TODO: handle error System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; } }
public ActionResult Create(Vendor model) { if (ModelState.IsValid) { int row = repo.Create(model); if (row > 0) { TempData["message"] = "Successfully Created"; } } else { fillDropdowns(); return(View(model)); } return(RedirectToAction("Create")); }
public static int CreateVendor(Vendor vendor) { if (vendor == null) { throw new System.ArgumentNullException() { Source = "vendor" }; } using (CustomClearviewEntities ctx = new CustomClearviewEntities()) { VendorRepository repo = new VendorRepository(ctx); repo.Create(vendor); ctx.SaveChanges(); } return(vendor.VendorId); }
public void Setup() { this.vr = new VendorRepository(); vr.Create(Comanche); }