public async Task <IActionResult> Edit(int id, [Bind("ShipperId,CompanyName,Phone")] Shippers shippers) { if (id != shippers.ShipperId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(shippers); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ShippersExists(shippers.ShipperId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(shippers)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Shippers shippers = db.Shippers.Find(id); if (shippers == null) { return(HttpNotFound()); } // List <Region> lstRegion = new List <Region>(); var regionList = from reg in db.Region select reg; foreach (Region region in regionList) { Region yksiRegion = new Region(); yksiRegion.RegionID = region.RegionID; yksiRegion.RegionDescription = region.RegionDescription; yksiRegion.RegionRegionDescription = region.RegionID + " - " + region.RegionDescription; lstRegion.Add(yksiRegion); } // ViewBag.RegionID = new SelectList(lstRegion, "RegionID", "RegionRegionDescription", shippers.RegionID); return(View(shippers)); }
// GET: Shippers/Delete/5 public ActionResult Delete(int id) { ShippersNegocio shippersNegocio = new ShippersNegocio(); Shippers shipper = shippersNegocio.GetOne(id); return(View(shipper)); }
public List <Shippers> getAllShippers() { List <Shippers> shippersList = new List <Shippers>(); Connection conn = new Connection(); SqlConnection connection = conn.SqlConnection; using (SqlCommand command = new SqlCommand("select * from Shippers", connection)) { try { connection.Open(); SqlDataReader dataReader = command.ExecuteReader(); while (dataReader.Read()) { Shippers shipper = new Shippers(dataReader.GetInt32(0), dataReader.GetString(1)); shipper.Phone = dataReader.IsDBNull(2) ? (string)null : dataReader.GetString(2); shippersList.Add(shipper); } dataReader.Close(); } catch (Exception exc) { logger.logError(DateTime.Now, "Error while trying to get all Shippers."); MessageBox.Show(exc.Message); } logger.logInfo(DateTime.Now, "GetAllShippers method has sucessfully invoked."); return(shippersList); } }
public IHttpActionResult PutShippers(int id, Shippers shippers) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != shippers.ShipperID) { return(BadRequest()); } db.Entry(shippers).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ShippersExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public int Insert(Shippers s) { NORTHWNDEntities db = new NORTHWNDEntities(); db.Shippers.Add(s); return(db.SaveChanges()); }
private void btnUpdate_Click(object sender, EventArgs e) { if (isAdd) { return; } if (!validation()) { return; } if (!isAdd) { Shippers sh = FormToShip(); int rs = SQLUpdate(sh); if (rs > 0) { // update UI DataGridViewRow row = dgShippers.SelectedRows[0]; row.Cells[COLUMN_COMPANY_NAME].Value = sh.CompanyName; row.Cells[COLUMN_PHONE].Value = sh.Phone; } else { MessageBox.Show("No row was updated. Tips: Try to sync.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
public void addRegion() { Shippers shipper = new Shippers("Brod"); index = repo.addShippers(shipper); Assert.IsTrue(index != 0); }
public async Task <IHttpActionResult> GuardarShipper(Shipper nuevo_shipper) { using (NorthwindEntities context = new NorthwindEntities()) { using (DbContextTransaction transaction = context.Database.BeginTransaction()) { try { if (nuevo_shipper != null) { Shippers Row = new Shippers() { CompanyName = nuevo_shipper.CompanyName, Phone = nuevo_shipper.Phone }; context.Shippers.Add(Row); await context.SaveChangesAsync(); transaction.Commit(); return(Ok(Row)); } else { return(BadRequest("Objeto Vacio")); } } catch (Exception ex) { transaction.Rollback(); return(BadRequest("ERROR FATAL")); } } } }
public ActionResult AddShipper(Shippers shipper) { db.Shippers.Add(shipper); db.SaveChanges(); return(RedirectToAction("Index")); //return View("Index"); }
private void btnAdd_Click(object sender, EventArgs e) { if (!isAdd) { return; } if (!validation()) { return; } Shippers sh = FormToShip(); if (isAdd) { int rs = SQLAdd(sh); if (rs > 0) // success { ResetForm(); LoadAllQuery(); } else // failed { MessageBox.Show("No row was added. Tips: Try to sync.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
async Task ExecuteLoadItemsCommand(object status) { if (IsBusy) { return; } IsBusy = true; try { var data = await DataStore.GetShipperDataAsync(); Shippers.Clear(); foreach (var item in data) { Shippers.Add(item); } await GetPalletsByStatus(Convert.ToString(status)); } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
public async Task <IActionResult> PutShippers([FromRoute] int id, [FromBody] Shippers shippers) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != shippers.ShipperId) { return(BadRequest()); } _context.Entry(shippers).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ShippersExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <Shippers> > PostShippers(Shippers shippers) { _context.Shippers.Add(shippers); await _context.SaveChangesAsync(); return(CreatedAtAction("GetShippers", new { id = shippers.ShipperId }, shippers)); }
public async Task ShipperEditEdits() { //Arrange Shippers shipperTest = new Shippers() { CompanyName = "Express", Phone = "0240-111-111" }; await _shippersControllerTest.Create(shipperTest); db.Entry(shipperTest).State = System.Data.Entity.EntityState.Added; var expectedShipper = db.Shippers.Find(shipperTest.ShipperID); db.Dispose(); shipperTest.CompanyName = "Nero Express"; shipperTest.Phone = "0240-222-222"; db = new NorthwindDatabase(); //Act await _shippersControllerTest.Edit(shipperTest); db.Entry(shipperTest).State = System.Data.Entity.EntityState.Modified; var actualShipper = db.Shippers.Find(shipperTest.ShipperID); //Assert Assert.AreEqual(expectedShipper, actualShipper); var shipper = db.Shippers.Where(s => (s.CompanyName == "Express" && s.Phone == "0240-111-111") || (s.CompanyName == "Nero Express" && s.Phone == "0240-222-222")); db.Shippers.RemoveRange(shipper); db.SaveChanges(); }
// GET: Orders public ActionResult Index(string ShipperID, string currentFilter1) { northwindEntities1 db = new northwindEntities1(); var orders = from p in db.Orders select p; if (!string.IsNullOrEmpty(ShipperID) && (ShipperID != "0")) { int para = int.Parse(ShipperID); orders = orders.Where(p => p.ShipVia == para); } List <Shippers> shipperit = new List <Shippers>(); var shipperList = from ship in db.Shippers select ship; Shippers tyhjaCategory = new Shippers(); tyhjaCategory.ShipperID = 0; tyhjaCategory.CompanyName = ""; shipperit.Add(tyhjaCategory); foreach (Shippers shipper in shipperList) { Shippers yksiCategory = new Shippers(); yksiCategory.ShipperID = shipper.ShipperID; yksiCategory.CompanyName = shipper.CompanyName; shipperit.Add(yksiCategory); } ViewBag.ShipperID = new SelectList(shipperit, "ShipperID", "CompanyName", ShipperID); return(View(orders)); }
public void updateShippers() { Shippers shipper = new Shippers("Brod"); int res = repo.updateShippers(shipper); Assert.IsTrue(res == 0); }
public string GetCompanyName(int shipperID) { List <Shippers> customers = this.getAllData(); Shippers shipper = customers.SingleOrDefault(m => m.ShipperID == shipperID); return((shipper != null) ? shipper.CompanyName : null); }
public ActionResult Edit(int?id) { if (Session["UserName"] == null) { ViewBag.LoggedStatus = "Logged out"; return(RedirectToAction("login", "home")); } else { ViewBag.LoggedStatus = "Logged in"; if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Shippers shippers = db.Shippers.Find(id); if (shippers == null) { return(HttpNotFound()); } ViewBag.RegionID = new SelectList(db.Region, "RegionID", "RegionDescription", shippers.RegionID); return(View(shippers)); } }
async Task ExecuteLoadItemsCommand() { try { Stores.Clear(); var palletMaster = await DataStore.GetPalletMaterDataAsync(); foreach (var item in palletMaster.Stores) { Stores.Add(item); } Status.Clear(); foreach (var item in palletMaster.Status) { Status.Add(item); } Categories.Clear(); foreach (var item in palletMaster.Categories) { Categories.Add(item); } Wrappers.Clear(); foreach (var item in palletMaster.Wrappers) { Wrappers.Add(item); } Shippers.Clear(); foreach (var item in palletMaster.Shippers) { Shippers.Add(item); } Suppliers.Clear(); foreach (var item in palletMaster.Suppliers) { Suppliers.Add(item); } Builders.Clear(); foreach (var item in palletMaster.Builders) { Builders.Add(item); } PalletTypes.Clear(); foreach (var item in palletMaster.PalletTypes) { PalletTypes.Add(item); } } catch (Exception ex) { Debug.WriteLine(ex); } }
public string Update(Shippers entity) { if (helper.ExecCommand($"Update Shippers set CompanyName='{entity.CompanyName}',Phone='{entity.Phone}' where ShipperID={entity.ShipperID}") > 0) { return("Güncelleme Başarılı"); } return("Güncelleme Başarısız"); }
public void AddShipper(Shippers shipper) { using (NorthwindModel northwind = new NorthwindModel()) { northwind.Shippers.Add(shipper); northwind.SaveChanges(); } }
public ActionResult AlterShip_partial(Shippers sh) { if (sh != null) { shippers.Update(sh); } return(RedirectToAction("Index")); }
//Câu 3 đề 3 public Shippers InsertShippADO(ShipperInsertReq req) { Shippers ship = new Shippers(); ship.CompanyName = req.CompanyName; ship.Phone = req.Phone; return(_rep.InsertShippADO(ship)); }
public ActionResult DeleteConfirmed(int id) { Shippers shippers = entities.Shippers.Find(id); entities.Shippers.Remove(shippers); entities.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int?id) { Shippers shipperi = db.Shippers.Find(id); db.Shippers.Remove(shipperi); db.SaveChanges(); return(RedirectToAction("Index")); }
public bool HireShipper(Shipper newShipper, string user, string password) { bool Confirmation; Shippers shipperManager = new Shippers(); Confirmation = shipperManager.AddShipper(newShipper, user, password); return(Confirmation); }
public async Task <Shippers> CreateShipper(Shippers shipper) { await _unitOfWork.Shippers.AddAsync(shipper); await _unitOfWork.CommitAsync(); return(shipper); }
// GET: Orders public ActionResult Index(string currentFilter1, string OrderShipper, string currentOrderShipper, int?page, int?pagesize) { // var orders = db.Orders.Include(o => o.Customers).Include(o => o.Employees).Include(o => o.Shippers); northwindEntities db = new northwindEntities(); var orders = from o in db.Orders.Include(o => o.Customers).Include(o => o.Employees).Include(o => o.Shippers).OrderBy(o => o.OrderDate) select o; //tuottekategoriahakufiltterin laitto muistiin if ((OrderShipper != null) && (OrderShipper != "0")) { page = 1; } else { OrderShipper = currentOrderShipper; } ViewBag.currentOrderShipper = OrderShipper; // filtering ONLY by shipper companies if (!String.IsNullOrEmpty(OrderShipper) && (OrderShipper != "0")) { int para = int.Parse(OrderShipper); orders = orders.Where(o => o.ShipVia == para); } //creating list for Categories dropdown List <Shippers> lstShippers = new List <Shippers>(); //bringing shippers to apumuuttuja var shippersList = from ship in db.Shippers select ship; Shippers tyhjaShipper = new Shippers(); //creating an empty category which is needed, if no category has been selected tyhjaShipper.ShipperID = 0; tyhjaShipper.CompanyName = ""; lstShippers.Add(tyhjaShipper); //bringing the shippers to the list foreach (Shippers shipper in shippersList) { Shippers yksiShipper = new Shippers(); yksiShipper.ShipperID = shipper.ShipperID; yksiShipper.CompanyName = shipper.CompanyName; lstShippers.Add(yksiShipper); } ViewBag.ShipperId = new SelectList(lstShippers, "ShipperID", "CompanyName", OrderShipper); //lopuks luodaan SelectLitin ja sijoitetaan sen Viewbagiin //the paged nutget extention needs a pagenumber int and a pagesize int which we send from view but if it would be null, we change it here because you cant have 0th page int pageSize = (pagesize ?? 10); int pageNumber = (page ?? 1); return(View(orders.ToPagedList(pageNumber, pageSize))); //return View(orders); }
private Shippers FormToShip() { Shippers ship = new Shippers(); ship.ID = txtShipperID.Text.Trim(); ship.CompanyName = txtCompanyName.Text.Trim(); ship.Phone = mtbPhone.Text.Trim(); return(ship); }
/// <summary> /// There are no comments for Shippers in the schema. /// </summary> public void AddToShippers(Shippers shippers) { base.AddObject("Shippers", shippers); }
/// <summary> /// Create a new Shippers object. /// </summary> /// <param name="companyName">Initial value of CompanyName.</param> /// <param name="shipperID">Initial value of ShipperID.</param> public static Shippers CreateShippers(string companyName, int shipperID) { Shippers shippers = new Shippers(); shippers.CompanyName = companyName; shippers.ShipperID = shipperID; return shippers; }
public static Shippers CreateShippers(int shipperID) { Shippers shippers = new Shippers(); shippers.ShipperID = shipperID; return shippers; }
partial void InsertShippers(Shippers instance);
partial void DeleteShippers(Shippers instance);
partial void UpdateShippers(Shippers instance);