Esempio n. 1
0
        public Dictionary<int, string> DeleteOrderCond(int user_id, int order_id)
        {
            OrderMgmtReference.OrderMgmtClient omc = new OrderMgmtReference.OrderMgmtClient();
            Dictionary<int, string> response = new Dictionary<int, string>();
            UserMgmtReference.UserMgmtClient umc = new UserMgmtReference.UserMgmtClient();
            if(umc.GetUserInfo(user_id).title.Equals("admin"))
            {
                response.Add(omc.DeleteOrder(order_id), "Orders Deleted");
            }
            else
            {
                response.Add(omc.DeleteOrderUser(user_id, order_id), "Orders Deleted");
            }

            return response;
        }
Esempio n. 2
0
        public List<OrderMgmtReference.Order> ViewOrdersCond(int user_id)
        {
            List<OrderMgmtReference.Order> orderList = new List<OrderMgmtReference.Order>();
            OrderMgmtReference.OrderMgmtClient omc = new OrderMgmtReference.OrderMgmtClient();
            UserMgmtReference.UserMgmtClient umc = new UserMgmtReference.UserMgmtClient();
            if (umc.GetUserInfo(user_id).title.Equals("admin"))
            {
                orderList = omc.GetOrderList().ToList();
            }
            else
            {
                orderList = omc.GetUserOrderList(user_id).ToList();
            }

            return orderList;
        }
Esempio n. 3
0
        public Dictionary<int, string> RegisterUser(string username, string name, string surname, string email, string phone, string city, string password)
        {
            Dictionary<int, string> response = new Dictionary<int, string>();
            UserMgmtReference.UserMgmtClient umc = new UserMgmtReference.UserMgmtClient();

            if (umc.UserExists(username))
            {
                response.Add(0, "Username exists. Please user another username.");
            }
            else
            {
                umc.InsertUser(username, name, surname, email, phone, city, password);
                response.Add(1, "You have registered succesfully.");
            }

            return response;
        }
Esempio n. 4
0
        public Dictionary<int, UserMgmtReference.User> LoginUser(string username, string password)
        {

            Dictionary<int, UserMgmtReference.User> response = new Dictionary<int, UserMgmtReference.User>();
            UserMgmtReference.UserMgmtClient umc = new UserMgmtReference.UserMgmtClient();

            int user_id = umc.GetExistingUserId(username, password);
            if (user_id == 0)
            {
                // username-password combination is wrong
                response.Add(0, new UserMgmtReference.User());
            }
            else
            {
                //username/password combo exists
                response.Add(1, umc.GetUserInfo(user_id));
            }

            return response;
        }