コード例 #1
0
    public string ChangeOrderStatus(int id, Boolean boolean)
    {
        try
        {
            TeeShopEntities db = new TeeShopEntities();

            //Fetch object from db
            Order o = db.Orders.Find(id);
            if (boolean == true)
            {
                o.Status = "delivered";
            }
            else
            {
                o.Status = "pendding";
            }



            db.SaveChanges();
            return(o.ID + " was successfully updated!");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
コード例 #2
0
    public void UpdateQuantity(int id, int quantity)
    {
        TeeShopEntities db = new TeeShopEntities();
        Cart            p  = db.Carts.Find(id);

        p.Amount = quantity;

        db.SaveChanges();
    }
コード例 #3
0
    public List <Cart> GetOrdersInCart(string clientId)
    {
        TeeShopEntities db     = new TeeShopEntities();
        List <Cart>     orders = (from x in db.Carts
                                  where x.ClientID == clientId &&
                                  x.IsInCart
                                  orderby x.DatePurchased descending
                                  select x).ToList();

        return(orders);
    }
コード例 #4
0
ファイル: SupplierModel.cs プロジェクト: mossgreen/TeeShop
    public Supplier GetSupplier(int id)
    {
        try
        {
            TeeShopEntities db       = new TeeShopEntities();
            Supplier        supplier = db.Suppliers.Find(id);

            return(supplier);
        }
        catch (Exception e)
        {
            return(null);
        }
    }
コード例 #5
0
ファイル: ClientModel.cs プロジェクト: mossgreen/TeeShop
    public string InsertClient(Client client)
    {
        try
        {
            TeeShopEntities db = new TeeShopEntities();
            db.Clients.Add(client);
            db.SaveChanges();

            return(client.UserName + " was succesfully inserted");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
コード例 #6
0
    public void MarkOrdersAsPaid(List <Cart> carts)
    {
        TeeShopEntities db = new TeeShopEntities();

        if (carts != null)
        {
            foreach (Cart cart in carts)
            {
                Cart oldCart = db.Carts.Find(cart.ID);
                oldCart.DatePurchased = DateTime.Now;
                oldCart.IsInCart      = false;
            }
            db.SaveChanges();
        }
    }
コード例 #7
0
    public string InsertCart(Cart cart)
    {
        try
        {
            TeeShopEntities db = new TeeShopEntities();
            db.Carts.Add(cart);
            db.SaveChanges();

            return(cart.DatePurchased + " was succesfully inserted");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
コード例 #8
0
ファイル: SupplierModel.cs プロジェクト: mossgreen/TeeShop
    public string InsertSupplier(Supplier supplier)
    {
        try
        {
            TeeShopEntities db = new TeeShopEntities();
            db.Suppliers.Add(supplier);
            db.SaveChanges();

            return(supplier.Name + " was successfully inserted!");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
コード例 #9
0
ファイル: ProductModel.cs プロジェクト: mossgreen/TeeShop
    public string InsertProduct(Product product)
    {
        try
        {
            TeeShopEntities db = new TeeShopEntities();
            db.Products.Add(product);
            db.SaveChanges();

            return(product.Name + " was succesfully inserted");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
コード例 #10
0
ファイル: ProductModel.cs プロジェクト: mossgreen/TeeShop
 public Product GetProduct(int id)
 {
     try
     {
         using (TeeShopEntities db = new TeeShopEntities())
         {
             Product product = db.Products.Find(id);
             return(product);
         }
     }
     catch (Exception)
     {
         return(null);
     }
 }
コード例 #11
0
    public string InsertOrder(Order order)
    {
        try
        {
            TeeShopEntities db = new TeeShopEntities();
            db.Orders.Add(order);
            db.SaveChanges();

            return(order.ID.ToString());
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
コード例 #12
0
 public List <Cart> GetAllCarts()
 {
     try
     {
         using (TeeShopEntities db = new TeeShopEntities())
         {
             List <Cart> carts = (from x in db.Carts
                                  select x).ToList();
             return(carts);
         }
     }
     catch (Exception)
     {
         return(null);
     }
 }
コード例 #13
0
ファイル: ProductModel.cs プロジェクト: mossgreen/TeeShop
 public List <Product> GetAllProducts()
 {
     try
     {
         using (TeeShopEntities db = new TeeShopEntities())
         {
             List <Product> products = (from x in db.Products
                                        select x).ToList();
             return(products);
         }
     }
     catch (Exception)
     {
         return(null);
     }
 }
コード例 #14
0
ファイル: ClientModel.cs プロジェクト: mossgreen/TeeShop
 public List <Client> GetAllCustomers()
 {
     try
     {
         using (TeeShopEntities db = new TeeShopEntities())
         {
             List <Client> clients = (from x in db.Clients
                                      select x).ToList();
             return(clients);
         }
     }
     catch (Exception e)
     {
         return(null);
     }
 }
コード例 #15
0
ファイル: ProductModel.cs プロジェクト: mossgreen/TeeShop
 public List <Product> GetProductsByType(int typeId)
 {
     try
     {
         using (TeeShopEntities db = new TeeShopEntities())
         {
             List <Product> products = (from x in db.Products
                                        where x.TypeID == typeId
                                        select x).ToList();
             return(products);
         }
     }
     catch (Exception)
     {
         return(null);
     }
 }
コード例 #16
0
    public int GetAmountOfOrders(string clientId)
    {
        try
        {
            TeeShopEntities db     = new TeeShopEntities();
            int             amount = (from x in db.Carts
                                      where x.ClientID == clientId &&
                                      x.IsInCart
                                      select x.Amount).Sum();

            return(amount);
        }
        catch
        {
            return(0);
        }
    }
コード例 #17
0
    public Order GetOrder(int OrderId)
    {
        try
        {
            TeeShopEntities db         = new TeeShopEntities();
            OrderModel      orderModel = new OrderModel();

            var order = (from x in db.Orders
                         where x.ID == OrderId
                         select x).FirstOrDefault();

            return(order);
        }
        catch (Exception ex)
        {
            return(null);
        }
    }
コード例 #18
0
ファイル: ProductModel.cs プロジェクト: mossgreen/TeeShop
    public string DeleteProduct(int id)
    {
        try
        {
            TeeShopEntities db      = new TeeShopEntities();
            Product         product = db.Products.Find(id);

            db.Products.Attach(product);
            db.Products.Remove(product);
            db.SaveChanges();

            return(product.Name + " was succesfully deleted");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
コード例 #19
0
    public string DeleteOrder(int id)
    {
        try
        {
            TeeShopEntities db    = new TeeShopEntities();
            Order           order = db.Orders.Find(id);

            db.Orders.Attach(order);
            db.Orders.Remove(order);
            db.SaveChanges();

            return(order.ID + " was successfully delected!");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
コード例 #20
0
ファイル: SupplierModel.cs プロジェクト: mossgreen/TeeShop
    public string DeleteSupplier(int id)
    {
        try
        {
            TeeShopEntities db       = new TeeShopEntities();
            Supplier        supplier = db.Suppliers.Find(id);

            db.Suppliers.Attach(supplier);
            db.Suppliers.Remove(supplier);
            db.SaveChanges();

            return(supplier.Name + " was successfully delected!");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
コード例 #21
0
ファイル: ClientModel.cs プロジェクト: mossgreen/TeeShop
    public string DeleteClient(int id)
    {
        try
        {
            TeeShopEntities db = new TeeShopEntities();
            Client          c  = db.Clients.Find(id);

            db.Clients.Attach(c);
            db.Clients.Remove(c);
            db.SaveChanges();

            return(c.UserName + " was succesfully deleted");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
コード例 #22
0
    public string DeleteCart(int id)
    {
        try
        {
            TeeShopEntities db   = new TeeShopEntities();
            Cart            cart = db.Carts.Find(id);

            db.Carts.Attach(cart);
            db.Carts.Remove(cart);
            db.SaveChanges();

            return(cart.DatePurchased + "was succesfully deleted");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
コード例 #23
0
ファイル: ClientModel.cs プロジェクト: mossgreen/TeeShop
    public Client GetClient(int Id)
    {
        try
        {
            TeeShopEntities db          = new TeeShopEntities();
            ClientModel     clientModel = new ClientModel();

            var customer = (from x in db.Clients
                            where x.ID == Id
                            select x).FirstOrDefault();

            return(customer);
        }
        catch (Exception ex)
        {
            return(null);
        }
    }
コード例 #24
0
    public string UpdateProductType(int id, ProductType productType)
    {
        try
        {
            TeeShopEntities db = new TeeShopEntities();

            //Fetch object from db
            ProductType p = db.ProductTypes.Find(id);

            p.Name = productType.Name;

            db.SaveChanges();
            return(productType.Name + " was succesfully updated");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
コード例 #25
0
ファイル: SupplierModel.cs プロジェクト: mossgreen/TeeShop
    public string UpdateSupplier(int id, Supplier supplier)
    {
        try
        {
            TeeShopEntities db = new TeeShopEntities();

            //Fetch object from db
            Supplier p = db.Suppliers.Find(id);

            p.Name        = supplier.Name;
            p.PhoneNumber = supplier.PhoneNumber;
            p.Email       = supplier.Email;

            db.SaveChanges();
            return(supplier.Name + " was successfully updated!");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
コード例 #26
0
    public string UpdateOrder(int id, Order order)
    {
        try
        {
            TeeShopEntities db = new TeeShopEntities();

            //Fetch object from db
            Order o = db.Orders.Find(id);

            o.ClientId    = order.ClientId;
            o.Status      = order.Status;
            o.TotalAmount = order.TotalAmount;
            o.OrderDate   = order.OrderDate;

            db.SaveChanges();
            return(order.ID + " was successfully updated!");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
コード例 #27
0
ファイル: ProductModel.cs プロジェクト: mossgreen/TeeShop
    public string UpdateProduct(int id, Product product)
    {
        try
        {
            TeeShopEntities db = new TeeShopEntities();

            //Fetch object from db
            Product p = db.Products.Find(id);

            p.Name        = product.Name;
            p.Price       = product.Price;
            p.TypeID      = product.TypeID;
            p.Description = product.Description;
            p.Image       = product.Image;

            db.SaveChanges();
            return(product.Name + " was succesfully updated");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
コード例 #28
0
    public string UpdateCart(int id, Cart cart)
    {
        try
        {
            TeeShopEntities db = new TeeShopEntities();

            //Fetch object from db
            Cart p = db.Carts.Find(id);

            p.DatePurchased = cart.DatePurchased;
            p.ClientID      = cart.ClientID;
            p.Amount        = cart.Amount;
            p.IsInCart      = cart.IsInCart;
            p.ProductID     = cart.ProductID;

            db.SaveChanges();
            return(cart.DatePurchased + " was succesfully updated");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }
コード例 #29
0
ファイル: ClientModel.cs プロジェクト: mossgreen/TeeShop
    public string UpdateClient(int id, Client client)
    {
        try
        {
            TeeShopEntities db = new TeeShopEntities();

            //Fetch object from db
            Client c = db.Clients.Find(id);

            c.UserName    = client.UserName;
            c.ID          = client.ID;
            c.Email       = client.Email;
            c.PhoneNumber = client.PhoneNumber;
            c.PhoneType   = client.PhoneType;
            c.Address     = client.Address;

            db.SaveChanges();
            return(c.UserName + " was succesfully updated");
        }
        catch (Exception e)
        {
            return("Error:" + e);
        }
    }