示例#1
0
        public string GetUserOrderHistory(Guid sessionID, string username)// UC 6.4
        {
            if (string.IsNullOrWhiteSpace(username) || sessionID == null || sessionID.Equals(Guid.Empty))
            {
                Logger.writeEvent("Invalid input while getting the user " + username + " history");
                return(Json.Create_json_response(false, new InvalidInputException()));
            }
            if (!newMarketFacade.IsloggedIn(sessionID))
            {
                Logger.writeEvent("GetUserOrderHistory failed | not logged in");
                return(Json.Create_json_response(false, new LoggedOutException()));
            }
            if (!newMarketFacade.IsRegisteredUser(username))
            {
                Logger.writeEvent("GetUserOrderHistory failed | not a registered user");
                return(Json.Create_json_response(false, new NotRegisterdException()));
            }

            if (!newMarketFacade.IsAdmin(sessionID))
            {
                Logger.writeEvent("GetUserOrderHistory failed | Not admin");
                return(Json.Create_json_response(false, new NotAdminException()));
            }
            return(newMarketFacade.GetUserOrderHistory(sessionID, username));
        }
示例#2
0
        private static string InitiateMarketFacade(string adminUsername, string adminPassword, ICommunicationNotificationAlerter communication,
                                                   out IMarketFacade newMarketFacade, bool useInMemoryDB)
        {
            if (string.IsNullOrEmpty(adminPassword) || string.IsNullOrWhiteSpace(adminUsername))
            {
                newMarketFacade = null;
                Logger.writeEvent("InitiateMarketFacade : Invalid input");
                return(Json.Create_json_response(false, "Invalid input"));
            }

            newMarketFacade = new MarketFacade(adminUsername, adminPassword, communication, useInMemoryDB);

            Logger.writeEvent("InitiateMarketFacade: Initialized Successfully");
            return(Json.Create_json_response(true, true));
        }
示例#3
0
        public static string Init(string adminUsername, string adminPassword, string?init_operations_loc, out NotificationManager notification,
                                  out PurchaseActions PurchaseActions, out UserActions UserActions, out StoreActions StoreActions, bool useInMemoryDB = false)
        {
            Logger.writeEvent("SetUp: Initailzing System");
            Json         = new JsonResponse();
            notification = new NotificationManager();
            string result = InitiateMarketFacade(adminUsername, adminPassword, notification, out IMarketFacade newMarketFacade, useInMemoryDB);

            PurchaseActions = new PurchaseActions(newMarketFacade);
            UserActions     = new UserActions(newMarketFacade);
            StoreActions    = new StoreActions(newMarketFacade);
            if (!Json.deserializeSuccess(result))// error on MarketFacade Init
            {
                return(result);
            }
            else if (!ExternalSystemsAreConnected(newMarketFacade))
            {
                Logger.writeEvent("SetUp: External Systems Error");
                return(Json.Create_json_response(false, "External Systems Error"));
            }
            else
            {
                if (init_operations_loc != null)
                {
                    try
                    {
                        string op_lines = File.ReadAllText(init_operations_loc);
                        Run_init_operations(op_lines, UserActions, StoreActions, PurchaseActions);
                    }
                    catch (Exception e)
                    {
                        Logger.writeError(e);
                        Logger.writeEvent("SetUp: Invalid operations File");
                        return(Json.Create_json_response(false, "Invalid operations File"));
                    }
                }
                Logger.writeEvent("SetUp: Initailzation Completed Successfully");
                return(result);
            }
        }
示例#4
0
 public string Register(Guid sessionID, string username, string password)// UC 2.2
 {
     if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password) ||
         sessionID == null || sessionID.Equals(Guid.Empty))
     {
         Logger.writeEvent("Invalid input in register");
         return(Json.Create_json_response(false, new InvalidInputException()));
     }
     return(newMarketFacade.Register(sessionID, username, password));
 }