Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 3
0
        public MyShipper GetShipperByShipperId(int id)
        {

            try
            {
                using (var db = new theDB())
                {
                    var shipper = (from s in db.Shippers
                                   where s.ShipperID == id
                                   select new MyShipper()
                                   {
                                       ShipperID = s.ShipperID,
                                       CompanyName = s.CompanyName,
                                       Phone = s.Phone
                                   }).FirstOrDefault();

                    if (shipper == null)
                        throw new FaultException("Could not find a Shipper with given ID");

                    return shipper;
                }
            }
            catch (Exception exc)
            {
                throw new FaultException(exc.Message);
            }

        }
Ejemplo n.º 4
0
        public MyShipper GetShipperByShipperId(int id)
        {
            try
            {
                using (var db = new theDB())
                {
                    var shipper = (from s in db.Shippers
                                   where s.ShipperID == id
                                   select new MyShipper()
                    {
                        ShipperID = s.ShipperID,
                        CompanyName = s.CompanyName,
                        Phone = s.Phone
                    }).FirstOrDefault();

                    if (shipper == null)
                    {
                        throw new FaultException("Could not find a Shipper with given ID");
                    }

                    return(shipper);
                }
            }
            catch (Exception exc)
            {
                throw new FaultException(exc.Message);
            }
        }