// PUT api/OrderStatus/5 public IHttpActionResult PutOrderStatu(int id, OrderStatusGrocer orderstatu) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != orderstatu.OrderStatusId) { return(BadRequest()); } db.Entry(orderstatu).State = System.Data.Entity.EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!OrderStatuExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetOrderStatu(int id) { OrderStatusGrocer orderstatu = db.OrderStatusGrocers.Find(id); if (orderstatu == null) { return(NotFound()); } return(Ok(orderstatu)); }
public IHttpActionResult PostOrderStatu(OrderStatusGrocer orderstatu) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.OrderStatusGrocers.Add(orderstatu); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = orderstatu.OrderStatusId }, orderstatu)); }
public IHttpActionResult DeleteOrderStatu(int id) { OrderStatusGrocer orderstatu = db.OrderStatusGrocers.Find(id); if (orderstatu == null) { return(NotFound()); } db.OrderStatusGrocers.Remove(orderstatu); db.SaveChanges(); return(Ok(orderstatu)); }
public IQueryable <GroceryOrder> GetGroceryOrdersByLoginId(int LoginId) { var items = db.GroceryOrders.Where(i => i.LoginId == LoginId); foreach (var item in items) { OrderStatusGrocer orderStatusGrocer = db.OrderStatusGrocers.Find(item.OrderStatusId); item.OrderStatusGrocer = orderStatusGrocer; PaymentStatu paymentStatus = db.PaymentStatus.Find(item.PaymentStatusId); item.PaymentStatu = paymentStatus; Login login = db.Logins.Find(item.LoginId); item.Login = login; Grocer grocer = db.Grocers.Find(item.GrocerId); item.Grocer = grocer; } return(db.GroceryOrders.OrderBy(a => a.GroceryOrderId)); }
// GET api/GroceryOrder public IQueryable <GroceryOrder> GetGroceryOrders() { var items = db.GroceryOrders; foreach (var item in items) { OrderStatusGrocer orderStatusGrocer = db.OrderStatusGrocers.Find(item.OrderStatusId); item.OrderStatusGrocer = orderStatusGrocer; PaymentStatu paymentStatus = db.PaymentStatus.Find(item.PaymentStatusId); item.PaymentStatu = paymentStatus; //Login login = db.Logins.Find(item.LoginId); //item.Login = login; //Grocer grocer = db.Grocers.Find(item.GrocerId); //item.Grocer = grocer; } return(db.GroceryOrders.OrderBy(a => (a.GroceryOrderId))); }