예제 #1
0
        public IHttpActionResult Get(int id = 0)
        {
            try
            {
                var ship = db.Shippers.Find(id);
                if (ship == null)
                {
                    return(NotFound());
                }

                var data = new ShipperViewModel()
                {
                    CompanyName = ship.CompanyName,
                    Phone       = ship.Phone,
                    ShipperID   = ship.ShipperID
                };
                return(Ok(new
                {
                    success = true,
                    data = data
                }));
            }
            catch (Exception ex)
            {
                return(BadRequest($"Bir hata oluştu {ex.Message}"));
            }
        }
예제 #2
0
 public IHttpActionResult Add([FromBody] ShipperViewModel model)
 {
     try
     {
         db.Shippers.Add(new Shipper()
         {
             CompanyName = model.CompanyName,
             Phone       = model.Phone,
         });
         db.SaveChanges();
         return(Ok(new
         {
             success = true,
             message = "Kargo Şirketi işlemi başarılı"
         }));
     }
     catch (Exception ex)
     {
         return(BadRequest($"Bir hata oluştu {ex.Message}"));
     }
 }