public static List <TransactionModel> getTransactionForSpecificUser(int id)
        {
            var joinQuery = from trans in DBSingleton.getDB().Transaction
                            join user in DBSingleton.getDB().MsUser
                            on trans.UserId equals user.UserId
                            join shoe in DBSingleton.getDB().ShoeTable
                            on trans.ProductId equals shoe.ShoeId
                            where user.UserId == id
                            select new TransactionModel
            {
                MemberName        = user.UserName,
                ProductName       = shoe.ShoeName,
                ProductPrice      = shoe.ShoePrice,
                Quantity          = trans.Quantity,
                Subtotal          = trans.Quantity * shoe.ShoePrice,
                TransactionDate   = trans.TransactionDate,
                TransactionStatus = trans.TransactionStatus,
                TransactionId     = trans.TransactionId
            };
            List <TransactionModel> joinList = new List <TransactionModel>();

            foreach (var item in joinQuery)
            {
                joinList.Add(item);
            }
            return(joinList);
        }
示例#2
0
        public static List <CartModel> getUserCart(int userId)
        {
            var joinQuery = from cart in DBSingleton.getDB().UserCart
                            join user in DBSingleton.getDB().MsUser
                            on cart.UserId equals user.UserId
                            join shoe in DBSingleton.getDB().ShoeTable
                            on cart.ShoeId equals shoe.ShoeId
                            //where user.UserId == userId && shoe.ShoeId == productId
                            select new CartModel
            {
                CartId    = cart.CartId,
                ShoeId    = shoe.ShoeId,
                UserId    = user.UserId,
                Quantity  = cart.Quantity,
                ShoeName  = shoe.ShoeName,
                ShoeImage = shoe.ShoeImage,
                ShoePrice = shoe.ShoePrice,
                SubTotal  = shoe.ShoePrice * cart.Quantity
            };

            //System.Diagnostics.Debug.WriteLine("JoinQuery = " + joinQuery);

            foreach (var str in joinQuery)
            {
                System.Diagnostics.Debug.WriteLine(str);
            }

            List <CartModel> joinList = new List <CartModel>();

            foreach (var item in joinQuery)
            {
                joinList.Add(item);
            }
            return(joinList);
        }
示例#3
0
        public static void updatePassword(int id, string pass)
        {
            List <MsUser> data       = UserRepository.getUserData();
            MsUser        updateUser = data.Where(y => y.UserId == id).SingleOrDefault();

            updateUser.UserPassword = pass;
            DBSingleton.getDB().SaveChanges();
        }
示例#4
0
        public static void incrementTotalSales(int id)
        {
            List <ShoeTable> data          = ShoeRepository.getShoeData();
            ShoeTable        incrementShoe = data.Where(y => y.ShoeId == id).SingleOrDefault();

            incrementShoe.TotalSales += 1;
            DBSingleton.getDB().SaveChanges();
        }
示例#5
0
        public static void updateUserToAdmin(int id)
        {
            List <MsUser> data       = UserRepository.getUserData();
            MsUser        updateUser = data.Where(y => y.UserId == id).SingleOrDefault();

            updateUser.UserRole = "U002";
            DBSingleton.getDB().SaveChanges();
        }
示例#6
0
        //Update
        public static void updateCart(int cartId, int userId, int shoeId, int quantity)
        {
            UserCart updateCart = DBSingleton.getDB().UserCart.Where(y => y.CartId == cartId).SingleOrDefault();

            updateCart.UserId   = userId;
            updateCart.ShoeId   = shoeId;
            updateCart.Quantity = quantity;
            DBSingleton.getDB().SaveChanges();
        }
        //Update
        public static void updateTransaction(int transactionId, string transactionStatus, int quantity, int subtotal)
        {
            Transaction updateCart = DBSingleton.getDB().Transaction.Where(y => y.TransactionId == transactionId).SingleOrDefault();

            updateCart.TransactionId     = transactionId;
            updateCart.TransactionStatus = transactionStatus;
            updateCart.Quantity          = quantity;
            updateCart.Subtotal          = subtotal;
            DBSingleton.getDB().SaveChanges();
        }
示例#8
0
        //Update
        public static void updateShoe(int id, string updateName, int updatePrice, int updateStock, string updateImage)
        {
            ShoeTable updateShoe = DBSingleton.getDB().ShoeTable.Where(y => y.ShoeId == id).SingleOrDefault();

            updateShoe.ShoeName  = updateName;
            updateShoe.ShoeStock = updateStock;
            updateShoe.ShoePrice = updatePrice;
            updateShoe.ShoeImage = updateImage;
            DBSingleton.getDB().SaveChanges();
        }
        //Update
        public static void updateUser(int id, string updateName, string email, string updatePassword, string gender, DateTime birthDate, string phoneNumber, string address, string profile, string userRole)
        {
            MsUser updateUser = DBSingleton.getDB().MsUser.Where(y => y.UserId == id).SingleOrDefault();

            updateUser.UserName     = updateName;
            updateUser.Email        = email;
            updateUser.UserPassword = updatePassword;
            updateUser.Gender       = gender;
            updateUser.BirthDate    = birthDate;
            updateUser.PhoneNumber  = phoneNumber;
            updateUser.Address      = address;
            updateUser.Profile      = profile;
            updateUser.UserRole     = userRole;
            DBSingleton.getDB().SaveChanges();
        }
示例#10
0
        public static CartModel getSpecificProductUserCart(int userId, int productId)
        {
            var joinQuery = from cart in DBSingleton.getDB().UserCart
                            join user in DBSingleton.getDB().MsUser
                            on cart.UserId equals user.UserId
                            join shoe in DBSingleton.getDB().ShoeTable
                            on cart.ShoeId equals shoe.ShoeId
                            where user.UserId == userId && shoe.ShoeId == productId
                            select new CartModel
            {
                CartId    = cart.CartId,
                ShoeId    = shoe.ShoeId,
                UserId    = user.UserId,
                Quantity  = cart.Quantity,
                ShoeName  = shoe.ShoeName,
                ShoeImage = shoe.ShoeImage,
                ShoePrice = shoe.ShoePrice
            };

            return(joinQuery.SingleOrDefault());
        }
示例#11
0
 //CRUD
 //Read
 public static List <ShoeTable> getShoeData()
 {
     try
     {
         List <ShoeTable> data = DBSingleton.getDB().ShoeTable.ToList();
         return(data);
     }
     catch
     {
         ShoeTable b = new ShoeTable()
         {
             ShoeId     = 0,
             ShoeImage  = "Error.jpg",
             ShoeName   = "Error",
             ShoePrice  = 0,
             ShoeStock  = 0,
             TotalSales = 0
         };
         List <ShoeTable> errorData = new List <ShoeTable>();
         errorData.Add(b);
         return(errorData);
     }
 }
示例#12
0
 public static UserRole findUserRole(string roleId)
 {
     return(DBSingleton.getDB().UserRole.Where(x => x.UserRoleId == roleId).SingleOrDefault());
 }
示例#13
0
 //CRUD
 //Read
 public static List <UserCart> getUserCart()
 {
     return(DBSingleton.getDB().UserCart.ToList());
 }
 //Delete
 public static void deleteTransaction(Transaction delTransaction)
 {
     DBSingleton.getDB().Transaction.Remove(delTransaction);
     DBSingleton.getDB().SaveChanges();
 }
示例#15
0
 public static void insertUser(MsUser newUser)
 {
     DBSingleton.getDB().MsUser.Add(newUser); //lamda exprestion
     DBSingleton.getDB().SaveChanges();
 }
示例#16
0
 //Delete
 public static void deleteUser(MsUser delUser)
 {
     DBSingleton.getDB().MsUser.Remove(delUser);
     DBSingleton.getDB().SaveChanges();
 }
示例#17
0
        //CRUD

        //Read
        public static List <MsUser> getUserData()
        {
            return(DBSingleton.getDB().MsUser.ToList());
        }
 public static void insertTransaction(Transaction newTransaction)
 {
     DBSingleton.getDB().Transaction.Add(newTransaction); //lamda exprestion
     DBSingleton.getDB().SaveChanges();
 }
示例#19
0
 //Delete
 public static void deleteCart(UserCart delCart)
 {
     DBSingleton.getDB().UserCart.Remove(delCart);
     DBSingleton.getDB().SaveChanges();
 }
示例#20
0
 public static void insertShoe(ShoeTable newShoe)
 {
     DBSingleton.getDB().ShoeTable.Add(newShoe); //lamda exprestion
     DBSingleton.getDB().SaveChanges();
 }
示例#21
0
 //Delete
 public static void deleteShoe(ShoeTable delShoe)
 {
     DBSingleton.getDB().ShoeTable.Remove(delShoe);
     DBSingleton.getDB().SaveChanges();
 }
示例#22
0
 public static void insertCart(UserCart newCart)
 {
     DBSingleton.getDB().UserCart.Add(newCart); //lamda exprestion
     DBSingleton.getDB().SaveChanges();
 }
 //CRUD
 //Read
 public static List <Transaction> getTransaction()
 {
     return(DBSingleton.getDB().Transaction.ToList());
 }