public IHttpActionResult Putorder_items(int id, order_items order_items) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != order_items.order_id) { return(BadRequest()); } db.Entry(order_items).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!order_itemsExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult Putcustomer(int id, customer customer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != customer.customer_id) { return(BadRequest()); } db.Entry(customer).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!customerExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult AddProduct([FromBody]product prod) { if (!ModelState.IsValid) { return BadRequest("Form your request properly please!"); } using (BikeStoresEntities entities = new BikeStoresEntities()) { product product = entities.products.Where(e => e.product_id == prod.product_id).FirstOrDefault<product>(); if (product != null) { product.product_id = prod.product_id; entities.SaveChanges(); } else { entities.products.Add(new product() { product_id = prod.product_id }); entities.SaveChanges(); } } return Ok(); }
public IHttpActionResult Putproduct(int id, product product) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != product.product_id) { return(BadRequest()); } db.Entry(product).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!productExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult Putstock(int id, StockVM stock) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != stock.store_id) { return(BadRequest()); } db.Entry(stock).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!stockExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Create([Bind(Include = "brand_id,brand_name")] brand brand) { if (ModelState.IsValid) { db.brands.Add(brand); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(brand)); }
public ActionResult Create([Bind(Include = "customer_id,first_name,last_name,phone,email,street,city,state,zip_code")] customer customer) { if (ModelState.IsValid) { db.customers.Add(customer); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customer)); }
public ActionResult Create([Bind(Include = "category_id,category_name")] category category) { if (ModelState.IsValid) { db.categories.Add(category); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(category)); }
public ActionResult Create([Bind(Include = "store_id,store_name,phone,email,street,city,state,zip_code")] store store) { if (ModelState.IsValid) { db.stores.Add(store); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(store)); }
public ActionResult Create([Bind(Include = "order_id,item_id,product_id,quantity,list_price,discount")] order_items order_items) { if (ModelState.IsValid) { db.order_items.Add(order_items); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.product_id = new SelectList(db.products, "product_id", "product_name", order_items.product_id); ViewBag.order_id = new SelectList(db.orders, "order_id", "order_id", order_items.order_id); return(View(order_items)); }
public ActionResult Create([Bind(Include = "store_id,product_id,quantity")] stock stock) { if (ModelState.IsValid) { db.stocks.Add(stock); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.product_id = new SelectList(db.products, "product_id", "product_name", stock.product_id); ViewBag.store_id = new SelectList(db.stores, "store_id", "store_name", stock.store_id); return(View(stock)); }
public ActionResult Create([Bind(Include = "product_id,product_name,brand_id,category_id,model_year,list_price")] product product) { if (ModelState.IsValid) { db.products.Add(product); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.brand_id = new SelectList(db.brands, "brand_id", "brand_name", product.brand_id); ViewBag.category_id = new SelectList(db.categories, "category_id", "category_name", product.category_id); return(View(product)); }
public ActionResult Create([Bind(Include = "staff_id,first_name,last_name,email,phone,active,store_id,manager_id")] staff staff) { if (ModelState.IsValid) { db.staffs.Add(staff); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.manager_id = new SelectList(db.staffs, "staff_id", "first_name", staff.manager_id); ViewBag.store_id = new SelectList(db.stores, "store_id", "store_name", staff.store_id); return(View(staff)); }
public ActionResult Create([Bind(Include = "order_id,customer_id,order_status,order_date,required_date,shipped_date,store_id,staff_id")] order order) { if (ModelState.IsValid) { db.orders.Add(order); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.customer_id = new SelectList(db.customers, "customer_id", "first_name", order.customer_id); ViewBag.staff_id = new SelectList(db.staffs, "staff_id", "first_name", order.staff_id); ViewBag.store_id = new SelectList(db.stores, "store_id", "store_name", order.store_id); return(View(order)); }
public static void AddCustomers(customers customers) { using (BikeStoresEntities db = new BikeStoresEntities()) { db.customers.Add(customers); db.SaveChanges(); } }
public static void UpdateCustomers(customers customers) { using (BikeStoresEntities db = new BikeStoresEntities()) { db.customers.Add(customers); db.Entry(customers).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } }
public static void DeleteCustomers(int customer_id) { using (BikeStoresEntities db = new BikeStoresEntities()) { var customers = new DataAccess.customers { customer_id = customer_id }; db.customers.Attach(customers); //db.customers.Remove(customers); db.Entry(customers).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); } }