public static List <Customers> GetCustomers(string gc) { using (SuSatisEntities db = new SuSatisEntities()) { return(db.Customers .Where(c => c.FirstName.Contains(gc)).OrderByDescending(c => c.CreateDate).ToList()); } }
public static List <Customers> GetCustomers(string searchQuery) { using (SuSatisEntities db = new SuSatisEntities()) { return(db.Customers .Where(c => c.firstName.Contains(searchQuery)) .OrderByDescending(c => c.createdAt) .ToList()); } }
public static List <Orders> GetOrders() { using (SuSatisEntities db = new SuSatisEntities()) { List <Orders> orders = db.Orders.Include("Customers"). OrderByDescending(o => o.CreateDate).ToList(); return(orders); } }
public static bool AddCustomer(Customers customer) { using (SuSatisEntities db = new SuSatisEntities()) { customer.createdAt = DateTime.Now; db.Customers.Add(customer); db.SaveChanges(); return(true); } }
public static Orders UpdateOrders(Orders o) { using (SuSatisEntities db = new SuSatisEntities()) { o.CreateDate = DateTime.Now; db.Entry(o).State = EntityState.Modified; db.Orders.Add(o); db.SaveChanges(); return(o); } }
public static Customers UpdateCustomers(Customers c) { using (SuSatisEntities db = new SuSatisEntities()) { c.CreateDate = DateTime.Now; db.Entry(c).State = EntityState.Modified; db.Customers.Add(c); db.SaveChanges(); return(c); } }
public static bool AddOrder(Orders order) { using (SuSatisEntities db = new SuSatisEntities()) { order.createdAt = DateTime.Now; db.Orders.Add(order); db.SaveChanges(); return(true); } }
public static bool DeleteAllOrders() { using (SuSatisEntities db = new SuSatisEntities()) { List <Orders> orders = GetOrders(); db.Orders.RemoveRange(db.Orders); db.SaveChanges(); return(true); } }
public static bool DeleteCustomer(int customerID) { using (SuSatisEntities db = new SuSatisEntities()) { Customers customer = db.Customers .Where(s => s.customerID == customerID) .FirstOrDefault(); db.Customers.Remove(customer); db.SaveChanges(); return(true); } }
public static bool DeleteOrder(int orderId) { using (SuSatisEntities db = new SuSatisEntities()) { Orders order = db.Orders .Where(s => s.orderID == orderId) .FirstOrDefault(); db.Orders.Remove(order); db.SaveChanges(); return(true); } }
public static bool UpdateOrderStatus(int orderId, string orderStatus) { using (SuSatisEntities db = new SuSatisEntities()) { Orders order = db.Orders.Where(o => o.orderID == orderId).FirstOrDefault(); order.status = orderStatus; order.createdAt = DateTime.Now; db.SaveChanges(); return(true); } }
public static List <Orders> GetTodaysOrders() { using (SuSatisEntities db = new SuSatisEntities()) { DateTime today = DateTime.Now; List <Orders> orders = db.Orders.Include("Customers"). OrderByDescending(o => o.CreateDate).Where(o => (o.CreateDate.Year == today.Year && o.CreateDate.Month == today.Month && o.CreateDate.Day == today.Day)).ToList(); return(orders); } }
static public bool DeleteOrders(int ID) { using (SuSatisEntities db = new SuSatisEntities()) { var orderdelete = db.Orders.Find(ID); db.Orders.Remove(orderdelete); if (db.SaveChanges() > 0) { return(true); } else { return(false); } } }
public static bool UpdateCustomer(int customerID, Customers updatedCustomer) { using (SuSatisEntities db = new SuSatisEntities()) { Customers customer = db.Customers .Where(c => c.customerID == customerID) .FirstOrDefault(); db.Customers.Remove(customer); updatedCustomer.createdAt = DateTime.Now; db.Customers.Add(updatedCustomer); db.SaveChanges(); return(true); } }
static public Orders AddOrders(Orders order) { using (SuSatisEntities db = new SuSatisEntities()) { order.CreateDate = DateTime.Now; db.Orders.Add(order); if (db.SaveChanges() > 0) { return(order); } else { return(order); } } }
static public Customers AddCustomers(Customers customer) { using (SuSatisEntities db = new SuSatisEntities()) { customer.CreateDate = DateTime.Now; db.Customers.Add(customer); if (db.SaveChanges() > 0) { return(customer); } else { return(customer); } } }