public string SaveShipper(MyShipper shipper) { try { using (var db = new theDB()) { var theShipper = (from s in db.Shippers where s.ShipperID == shipper.ShipperID select s).FirstOrDefault(); if (theShipper == null) throw new FaultException("Shipper was not saved because there is no Shipepr with given ID"); theShipper.CompanyName = shipper.CompanyName; theShipper.Phone = shipper.Phone; db.SaveChanges(); return "Shipper was edited successfully"; } } catch (Exception exc) { throw new FaultException(exc.Message); } }
public string SaveShipper(MyShipper shipper) { try { using (var db = new theDB()) { var theShipper = (from s in db.Shippers where s.ShipperID == shipper.ShipperID select s).FirstOrDefault(); if (theShipper == null) { throw new FaultException("Shipper was not saved because there is no Shipepr with given ID"); } theShipper.CompanyName = shipper.CompanyName; theShipper.Phone = shipper.Phone; db.SaveChanges(); return("Shipper was edited successfully"); } } catch (Exception exc) { throw new FaultException(exc.Message); } }
public void SaveShipper(MyShipper shipper) { try { var nwshipper = context.Shippers.SingleOrDefault(s => s.ShipperID == shipper.ShipperId); if (nwshipper != null) { nwshipper.Phone = shipper.Phone; nwshipper.CompanyName = shipper.CompanyName; } context.SaveChanges(); } catch (CommunicationException ex) { throw new Exception(ex.Message); } }
public MyShipper GetShipper(int shipperId) { try { var newshipper = context.Shippers.SingleOrDefault(s => s.ShipperID == shipperId); MyShipper shipper = new MyShipper(); if (newshipper != null) { shipper.ShipperId = newshipper.ShipperID; shipper.CompanyName = newshipper.CompanyName; shipper.Phone = newshipper.Phone; } return shipper; } catch (CommunicationException ex) { throw new Exception(ex.Message); } }