示例#1
0
        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);
            }
        }
示例#2
0
        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);
            }
        }
示例#3
0
        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);
            }
           
        }
示例#4
0
 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);
     }
     
 }