Пример #1
0
        public static string[] getOfferRequestToAnswer(string username, int requestID)
        {
            aUser requestsHolder = getUser(username);

            if (requestsHolder == null)
            {
                return(null);
            }

            OfferRequest request = requestsHolder.getRequestToAnswer(requestID);

            if (request == null)
            {
                return(null);
            }

            // convert it to string array
            string[] requestString = new string[7]; // the length is equal to the number of relevant fields in OfferRequest

            requestString[0] = "" + request.id;
            requestString[1] = request.requester.getUserName();
            requestString[2] = request.store.name;
            requestString[3] = request.product.info.ToString();
            requestString[4] = "" + request.product.amount;
            requestString[5] = "" + request.getPrice();
            requestString[6] = "" + request.status;

            return(requestString);
        }
Пример #2
0
        // aUser
        public static bool saveProduct(string username, string storeName, string manufacturer, Dictionary <string, int> product)
        {
            aUser temp = getUser(username);

            if (temp == null)
            {
                return(false);
            }
            Store store = browseStore(username, storeName);

            if (store == null)
            {
                return(false);
            }
            ShoppingBasket basket = new ShoppingBasket(store, temp);

            foreach (string pName in product.Keys)
            {
                Product p1 = Stores.searchStore(storeName).searchProduct(pName, manufacturer);
                p1.amount = product[pName];
                basket.addProduct(p1);
            }

            return(temp.saveProduct(basket));
        }
Пример #3
0
        public static string[] purchase(string username, string creditNumber, string validity, string cvv)
        {
            /*
             * PaymentMethod p = null;
             * switch (paymentName)
             * {
             *  case "Immediate":
             *      p = new Immediate();
             *      break;
             *  case "Offer":
             *      p = new Offer();
             *      break;
             *  case "Auction":
             *      p = new Auction();
             *      break;
             *  case "Raffle":
             *      p = new Raffle();
             *      break;
             * }*/
            aUser temp = getUser(username);

            if (temp == null)
            {
                return new string[] { "false", "user not exist" }
            }
            ;
            return(temp.purchase(creditNumber, validity, cvv));
        }
Пример #4
0
        public static bool leaveFeedback(string username, string storeName, string productName, string manufacturer, string comment)
        {
            aUser temp = getUser(username);

            /* if (!temp.canLeaveFeedback)
             *   return false;*/
            return(Stores.searchStore(storeName).searchProduct(productName, manufacturer).info.leaveFeedback(username, comment));
        }
Пример #5
0
        public static bool EstablishStore(string username, string storeName)
        {
            aUser temp = getUser(username);

            if (temp == null)
            {
                return(false);
            }
            return(temp.EstablishStore(storeName));
        }
Пример #6
0
        public static ShoppingBasket getBasket(string username, string storeName)
        {
            aUser temp = getUser(username);

            if (temp == null)
            {
                return(null);
            }
            return(temp.getBasket(Stores.searchStore(storeName)));
        }
Пример #7
0
        public static bool hireNewStoreManager(string username, string storeName, string userToHire)
        {
            aUser temp = getUser(username);

            if (temp == null || getUser(userToHire) == null)
            {
                return(false);
            }
            return(temp.hireNewStoreManager(storeName, userToHire));
        }
Пример #8
0
        public static bool supply(string username, string storeName, string productName, int amount, string manufacturer)
        {
            aUser temp = getUser(username);

            if (temp == null)
            {
                return(false);
            }
            return(temp.supply(storeName, productName, amount, manufacturer));
        }
Пример #9
0
        public static bool editProduct(string username, string storeName, string productName, double price, string manufacturer)
        {
            aUser temp = getUser(username);

            if (temp == null)
            {
                return(false);
            }
            return(temp.editProduct(storeName, productName, price, manufacturer));
        }
Пример #10
0
        public static bool addNewProduct(string username, string storeName, string productName, double price, int amount, string category, string manufacturer)
        {
            aUser temp = getUser(username);

            if (temp == null)
            {
                return(false);
            }
            return(temp.addNewProduct(storeName, productName, price, amount, category, manufacturer));
        }
Пример #11
0
        public static ICollection <Receipt> getAllReceiptsHistory(string username, string storeName)
        {
            aUser temp = getUser(username);

            if (temp == null)
            {
                return(null);
            }
            return(temp.getPurchaseHistory(storeName));
        }
Пример #12
0
        public static ICollection <Receipt> getAllMyReceiptHistory(string username)
        {
            aUser temp = getUser(username);

            if (temp == null)
            {
                return(null);
            }
            return(temp.getPurchHistory());
        }
Пример #13
0
        public static Store browseStore(string username, string storeName)
        {
            aUser temp = getUser(username);

            if (temp == null)
            {
                return(null);
            }
            return(temp.browseStore(storeName));
        }
Пример #14
0
        public static Dictionary <Store, Product> browseProducts(string username, string productName, string category, string manufacturer, double minPrice, double maxPrice)
        {
            aUser temp = getUser(username);

            if (temp == null)
            {
                return(null);
            }
            return(temp.browseProducts(productName, category, manufacturer, minPrice, maxPrice));
        }
Пример #15
0
        public static Dictionary <Store, Product> browseProducts(string username, string productName, string manufacturer)
        {
            aUser temp = getUser(username);

            if (temp == null)
            {
                return(null);
            }
            return(temp.browseProducts(productName, manufacturer));
        }
Пример #16
0
        public static double checkPrice(string username)
        {
            aUser temp = getUser(username);

            if (temp == null)
            {
                return(-1);
            }
            return(temp.checkPrice());
        }
Пример #17
0
        public static bool removeOwner(string username, string storeName, string userToHire)
        {
            aUser temp = getUser(username);

            if (temp == null || getUser(userToHire) == null || username.Equals(userToHire))
            {
                return(false);
            }
            return(temp.removeOwner(storeName, userToHire));
        }
Пример #18
0
        public static bool hireNewStoreOwner(string username, string storeName, string userToHire, List <string> Permissions)
        {
            aUser temp = getUser(username);

            if (temp == null || getUser(userToHire) == null)
            {
                return(false);
            }
            return(temp.hireNewStoreOwner(storeName, userToHire, convertPermission(Permissions)));
        }
Пример #19
0
        public static ShoppingCart getCart(string username)
        {
            aUser temp = getUser(username);

            if (temp == null)
            {
                return(null);
            }
            return(temp.getCart());
        }
Пример #20
0
        public static ICollection <Member> getInfoEmployees(string username, string storeName)
        {
            aUser temp = getUser(username);

            if (temp == null)
            {
                return(null);
            }
            return(temp.getInfoEmployees(storeName));
        }
Пример #21
0
        public static bool acceptOfferRequest(string acceptorUsername, int requestID)
        {
            aUser acceptor = getUser(acceptorUsername);

            if (acceptor == null)
            {
                return(false);
            }

            return(acceptor.acceptRequest(requestID));
        }
Пример #22
0
        public static bool negotiateOffer(string negotiatorUsername, int requestID, double price)
        {
            aUser negotiator = getUser(negotiatorUsername);

            if (negotiator == null)
            {
                return(false);
            }

            return(negotiator.negotiateRequest(requestID, price));
        }
Пример #23
0
        public static bool rejectOfferRequest(string rejectorUsername, int requestID)
        {
            aUser rejector = getUser(rejectorUsername);

            if (rejector == null)
            {
                return(false);
            }

            return(rejector.rejectOffer(requestID));
        }
Пример #24
0
 public static bool sendMessage(string username, string userToSend, string storeToSend, string msg, string storeRecive)
 {
     if (userToSend != null && userToSend.Length > 0)
     {
         aUser temp = getUser(userToSend);
         return(temp.sendMessage(new Message(storeRecive, storeToSend, userToSend, msg, true)));
     }
     else if (storeToSend != null && storeToSend.Length > 0)
     {
         Store temp = Stores.searchStore(storeToSend);
         return(temp.sendMessage(new Message(username, storeToSend, userToSend, msg, true)));
     }
     return(false);
 }
Пример #25
0
        public static int placeOffer(string username, string storeName, string productName, string category, string manufacturer, int amount, double price)
        {
            aUser       requester = getUser(username);
            Store       store     = Stores.searchStore(storeName);
            ProductInfo pInfo     = ProductInfo.getProductInfo(productName, category, manufacturer);

            if (requester == null | store == null | pInfo == null | price < 0)
            {
                return(-1);
            }

            Product      product = new Product(pInfo, amount, price);
            OfferRequest request = new OfferRequest(product, requester, store);

            requester.placeOffer(request);
            return(request.id);
        }
Пример #26
0
        public static int[] getOfferRequestsToAnswerIDs(string username)
        {
            aUser requestsHolder = getUser(username);

            if (requestsHolder == null)
            {
                return(null);
            }

            OfferRequest[] requests    = requestsHolder.getRequestsToAnswer().ToArray <OfferRequest>();
            int[]          requestsIDs = new int[requests.Count()];

            for (int i = 0; i < requestsIDs.Length; i++)
            {
                requestsIDs[i] = requests[i].id;
            }

            return(requestsIDs);
        }
Пример #27
0
        public static string[] GetPermissions(string username, string storeName)
        {
            aUser temp = getUser(username);

            if (temp == null)
            {
                return(null);
            }
            var list = temp.GetPermissions(storeName);

            string[] persmissions = new string[list.Count];
            int      i            = 0;

            foreach (PersmissionsTypes type in list)
            {
                persmissions[i] = (aPermission.who(type));
                i++;
            }
            return(persmissions);
        }
Пример #28
0
        public static string[] getMessages(string username)
        {
            aUser temp = getUser(username);

            if (temp == null)
            {
                return(null);
            }
            var msg = ((Member)temp).messages;

            string[] ans = new string[msg.Count];
            int      i   = 0;

            foreach (Message message in msg)
            {
                ans[i] = message.SenderName + "$" + message.StoreToSend + "$" + message.UserToSend + "$" + message.Msg + "$" + message.isNew.ToString();
                i++;
            }
            return(ans);
        }
Пример #29
0
        public static string[] GetMyStores(string username)
        {
            aUser temp = getUser(username);

            if (temp == null)
            {
                return(null);
            }
            var list = temp.GetAllPermissions();

            if (list != null)
            {
                string[] persmissions = new string[list.Count];
                int      i            = 0;
                foreach (string type in list.Keys)
                {
                    persmissions[i] = type;
                    i++;
                }
                return(persmissions);
            }
            return(null);
        }
Пример #30
0
        public static string[] getMessages(string username, string storename)
        {
            aUser temp = getUser(username);

            if (temp == null)
            {
                return(null);
            }
            if (storename.Length == 0)
            {
                return(getMessages(username));
            }
            var msg = Stores.searchStore(storename).messages;

            string[] ans = new string[msg.Count];
            int      i   = 0;

            foreach (Message message in msg)
            {
                ans[i] = message.SenderName + "$" + message.StoreToSend + "$" + message.UserToSend + "$" + message.Msg + "$" + message.isNew.ToString();
                i++;
            }
            return(ans);
        }