public IActionResult Create([Bind("VendorID,Name,Phone,LoginName,LoginPassword,Comment")] Vendor vendor) { if (ModelState.IsValid) { vendorRepo.AddVendor(vendor); return(RedirectToAction(nameof(Index))); } return(View(vendor)); }
public CommonResponseViewModel SaveVendor(VendorViewModel vendorVM) { if (vendorVM.id > 0) { return(_VendorRepository.UpdateVendor(vendorVM)); } else { return(_VendorRepository.AddVendor(vendorVM)); } }
public ActionResult <VendorDto> AddVendor(VendorForCreationDto vendorForCreation) { var vendor = _mapper.Map <Vendor>(vendorForCreation); _vendorRepository.AddVendor(vendor); _vendorRepository.Save(); var vendorDto = _mapper.Map <VendorDto>(vendor); return(CreatedAtRoute("GetVendor", new { vendorDto.VendorId }, vendorDto)); }
public HttpResponseMessage AddCountry([FromBody] VendorViewModel model) { try { var data = repo.AddVendor(model); if (data != null) { return(Request.CreateResponse(HttpStatusCode.OK, new { success = true, result = model, message = "The record has suucessfully been created" })); } return(Request.CreateResponse(HttpStatusCode.OK, new { success = false, result = model, message = "There was error creating this record" })); } catch (Exception e) { return(Request.CreateResponse(HttpStatusCode.OK, new { success = false, result = model, message = $"There was error creating this record {e.Message}" })); } }
public async Task AddVendor(Vendor vendor) { await _vendorRepository.AddVendor(vendor); }
/// <summary> /// Upload the data into the databases. /// </summary> public void UploadData() { List <long> commitTimes = new List <long>(); var readTimer = new Stopwatch(); readTimer.Start(); var vr = new CsvHelper.CsvReader(File.OpenText(Path.Combine(dataPath, "vendor-master.csv"))); vr.Configuration.HasHeaderRecord = false; vr.Configuration.RegisterClassMap <VendorMap>(); vr.Configuration.DetectColumnCountChanges = true; var ir = new CsvHelper.CsvReader(File.OpenText(Path.Combine(dataPath, "inv-master.csv"))); ir.Configuration.HasHeaderRecord = false; ir.Configuration.DetectColumnCountChanges = true; int z = 0; var writeTimer = new Stopwatch(); Vendor vendor; Inventory inv; while (vr.Read()) { writeTimer.Start(); int y = z + 5; vendor = vr.GetRecord <Vendor>(); vendorRepo.AddVendor(vendor); for (int x = z; x < y; x++) { if (ir.Read()) { inv = new Inventory(vendor.VendorName) { Category = ir.GetField(2), Name = ir.GetField(3), Price = ir.GetField <double>(0), Quantity = ir.GetField <int>(1) }; invRepo.AddInventory(ir.GetField(5), inv); } else { log.LogCritical($"{DateTime.Now}\tno more inventory"); } } z = y; writeTimer.Stop(); commitTimes.Add(writeTimer.ElapsedTicks); writeTimer.Reset(); } vendorRepo.Save(); readTimer.Stop(); log.LogInformation("-----------------------------"); log.LogInformation(""); log.LogInformation(""); log.LogInformation($"Read of CSV files took {readTimer.Elapsed.Minutes}:{readTimer.Elapsed.Seconds}.{readTimer.Elapsed.Milliseconds}."); readTimer.Reset(); readTimer.Start(); vendorRepo.Save(); invRepo.Save(); readTimer.Stop(); log.LogInformation($"syncing databases took {readTimer.ElapsedMilliseconds} milliseconds."); log.LogInformation(""); log.LogInformation($" Average write for each iteration (1 vendor, 5 inventory) averaged {commitTimes.Average()} ticks. Min: {commitTimes.Min()} Max: {commitTimes.Max()}"); }
public async Task <CommonResponse> AddVendor(VendorModel vendorModel) { return(await _vendorRepository.AddVendor(vendorModel)); }
private void AddVendor(Vendor vendor) { _vendorRepository.AddVendor(vendor); _transactionRepository.UpdateTransactionVendors(vendor); UpdateViewModels(); }