public IHttpActionResult PostCard(Card card) { if (!ModelState.IsValid) { return(BadRequest("Please Check Your Data")); } _context.Cards.Add(card); _context.SaveChanges(); return(Created(new Uri(Request.RequestUri + "/" + card.UserID), card)); }
public IHttpActionResult CreateProduct(Product product) { if ((!ModelState.IsValid) || product.Name == "" || product.NumInStock == 0 || product.Price == 0) { return(BadRequest("Please check your data")); } _context.Products.Add(product); _context.SaveChanges(); return(Created(new Uri(Request.RequestUri + "/" + product.ID), product)); }
public IHttpActionResult CreateFactory(Factory factory) { if ((!ModelState.IsValid) || factory.Name == "" || factory.Description == "") { return(BadRequest("Please check your data")); } _context.Factories.Add(factory); _context.SaveChanges(); return(Created(new Uri(Request.RequestUri + "/" + factory.ID), factory)); }
public IHttpActionResult CreateUser(User user) { if ((!ModelState.IsValid) || user.UserName == "" || user.Password == "" || user.Type == "") { return(BadRequest("Please check Your Data")); } _context.Users.Add(user); _context.SaveChanges(); return(Created(new Uri(Request.RequestUri + "/" + user.ID), user)); }
public IHttpActionResult Buy(Buying buying) { if ((!ModelState.IsValid) || buying.Name == "" || buying.Phone == "" || buying.Address == "" || buying.TotalPrice == 0) { return(BadRequest("Please check your data")); } if (buying.ProductID == "") { return(BadRequest("Please select items to buy")); } _context.Buyings.Add(buying); _context.SaveChanges(); return(Created(new Uri(Request.RequestUri + "/" + buying.ID), buying)); }