示例#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 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);
        }
    }
示例#4
0
    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);
        }
    }
示例#5
0
    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 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);
        }
    }
示例#7
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();
        }
    }
示例#8
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);
        }
    }
示例#9
0
    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);
        }
    }
示例#10
0
    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);
        }
    }
示例#11
0
    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);
        }
    }
示例#12
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);
        }
    }
示例#13
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);
        }
    }
示例#14
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);
        }
    }
示例#15
0
    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);
        }
    }
示例#16
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);
        }
    }
示例#17
0
    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);
        }
    }
示例#18
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);
        }
    }
示例#19
0
    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);
        }
    }