Example #1
0
 public MapEventStore(Map map, StoreMenu storeMenu, DialogMenu dialog)
 {
     this.eventType = EventType.STORE;
     this.store     = storeMenu;
     this.dialog    = dialog;
 }
Example #2
0
 public CloseStoreDialogMsg(StoreMenu storeMenu)
 {
     this.storeMenu = storeMenu;
 }
Example #3
0
 public void OnStorePressed()
 {
     StoreMenu.Open();
 }
Example #4
0
 public OpenStoreDialogMsg(StoreMenu storeMenu)
 {
     this.storeMenu = storeMenu;
 }
Example #5
0
        /// <summary>
        /// Main starting point of out program.
        /// </summary>
        public static void Main()
        {
            Console.OutputEncoding = Encoding.UTF8;
            Console.SetWindowSize(GeneralConstants.ConsoleWindowWidth, GeneralConstants.ConsoleWindowHeight);

#if DEBUG
            var collection = new List <IProduct>();
            collection.Add(new Dairy("Milk", 22.5m, DateTime.Now, 90, 32.1));
            collection.Add(new Dairy("Yougurt", 35.5m, DateTime.Now, 50, 5));
#endif
            string username = null;
            string password = null;
            string email    = null;

            StateType state = StateType.MainMenu;

            IStoreFactory storeFactory = StoreFactory.Instance;
            IUser         currentUser  = null;
            IDataStorage  userContext  = null;

            ConsoleKey key = ConsoleKey.NoName;

            while (true)
            {
                try
                {
                    switch (state)
                    {
                    case StateType.MainMenu:
                        MainMenu.Instance.Draw();
                        state = MainMenu.Instance.ParseKey(Console.ReadKey().Key);
                        break;

                    case StateType.LoginMenu:
                        //Validator.CheckIfPriceIsValid(-20);
                        LoginMenu.Instance.Draw();
                        state = LoginMenu.Instance.ParseKey(Console.ReadKey().Key);
                        break;

                    case StateType.RegisterMenu:
                        RegisterMenu.Instance.Draw();
                        state = RegisterMenu.Instance.ParseKey(Console.ReadKey().Key);
                        break;

                    case StateType.StoreMenu:
                        StoreMenu.Instance(collection).Draw();
                        state = StoreMenu.Instance(collection).ParseKey(Console.ReadKey().Key);
                        break;

                    case StateType.CartMenu:
                        CartMenu.Instance(currentUser.Cart).Draw();
                        state = CartMenu.Instance(currentUser.Cart).ParseKey(Console.ReadKey().Key);
                        break;

                    case StateType.PaymentMenu:
                        PaymentMenu.Instance.Draw();
                        state = PaymentMenu.Instance.ParseKey(Console.ReadKey().Key);
                        break;

                    case StateType.EnterUsername:
                        username = Console.ReadLine();
                        state    = StateType.RegisterMenu;
                        break;

                    case StateType.EnterPassword:
                        password = Console.ReadLine();
                        state    = StateType.RegisterMenu;
                        break;

                    case StateType.EnterEmail:
                        email = Console.ReadLine();
                        state = StateType.RegisterMenu;
                        break;

                    case StateType.Register:
                        userContext = storeFactory.CreateDataStorage("Users");
                        currentUser = storeFactory.CreateUser(typeof(Admin),
                                                              username, password, email);
                        userContext.Write(currentUser.ToString());
                        state = StateType.StoreMenu;
                        break;

                    case StateType.Login:
                        userContext = storeFactory.CreateDataStorage("Users");
                        var text = (userContext as FileStorage).ReadToEnd().Split('\n');
                        foreach (var str in text)
                        {
                            var temp = str.Split('|');
                            if (temp[1] == username && temp[2] == password)
                            {
                                currentUser = storeFactory.CreateUser(typeof(Admin), username, password, email);
                                break;
                            }
                        }

                        if (currentUser == null)
                        {
                            state = StateType.MainMenu;
                        }
                        else
                        {
                            state = StateType.StoreMenu;
                        }

                        break;

                    case StateType.NotSet:
                        state = ChangeMenuTemp(Console.ReadKey().Key, state);
                        break;

                    case StateType.AddToCart:
                        IProduct wantedProduct = TakeProductID(collection);
                        wantedProduct.Quantity--;
                        currentUser.Cart.AddToCart(wantedProduct);

                        if (wantedProduct.Quantity == 0)
                        {
                            collection.Remove(wantedProduct);
                        }

                        state = ChangeMenuTemp(Console.ReadKey().Key, state);
                        break;

                    default:
                        break;
                    }
                    Console.Clear();
                }
                catch (Exception ex)
                {
                    state = StateType.NotSet;
                    Console.WriteLine(ex.Message);
                }
            }
        }
Example #6
0
        /// <summary>
        ///
        /// </summary>
        /// <exception cref="pointofsale.cloud.doordash.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="payload"></param>
        /// <param name="userAgent">Your company identity. Format is [name]/[version]. like &#39;Sicom/1.0&#39; (optional)</param>
        /// <param name="authorization">The access token. Format is [type] [credentials]. like &#39;Bearer $101$gkeikcha3&#39; (optional)</param>
        /// <returns>Task of ApiResponse</returns>
        public async System.Threading.Tasks.Task <ApiResponse <Object> > PostMenuListViewAsyncWithHttpInfo(StoreMenu payload, string userAgent = null, string authorization = null)
        {
            // verify the required parameter 'payload' is set
            if (payload == null)
            {
                throw new ApiException(400, "Missing required parameter 'payload' when calling Apiv1menusApi->PostMenuListView");
            }

            var    localVarPath         = "/api/v1/menus";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new List <KeyValuePair <String, String> >();
            var    localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json"
            };
            String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/json"
            };
            String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            if (userAgent != null)
            {
                localVarHeaderParams.Add("User-Agent", Configuration.ApiClient.ParameterToString(userAgent));                    // header parameter
            }
            if (authorization != null)
            {
                localVarHeaderParams.Add("Authorization", Configuration.ApiClient.ParameterToString(authorization));                        // header parameter
            }
            if (payload != null && payload.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(payload); // http body (model) parameter
            }
            else
            {
                localVarPostBody = payload; // byte array
            }

            // authentication (Authorization) required
            if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("Authorization")))
            {
                localVarHeaderParams["Authorization"] = Configuration.GetApiKeyWithPrefix("Authorization");
            }

            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)await Configuration.ApiClient.CallApiAsync(localVarPath,
                                                                                                       Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                                       localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("PostMenuListView", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <Object>(localVarStatusCode,
                                            localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                            null));
        }
Example #7
0
 /// <summary>
 ///
 /// </summary>
 /// <exception cref="pointofsale.cloud.doordash.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="payload"></param>
 /// <param name="userAgent">Your company identity. Format is [name]/[version]. like &#39;Sicom/1.0&#39; (optional)</param>
 /// <param name="authorization">The access token. Format is [type] [credentials]. like &#39;Bearer $101$gkeikcha3&#39; (optional)</param>
 /// <returns>Task of void</returns>
 public async System.Threading.Tasks.Task PostMenuListViewAsync(StoreMenu payload, string userAgent = null, string authorization = null)
 {
     await PostMenuListViewAsyncWithHttpInfo(payload, userAgent, authorization);
 }
Example #8
0
 /// <summary>
 ///
 /// </summary>
 /// <exception cref="pointofsale.cloud.doordash.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="payload"></param>
 /// <param name="userAgent">Your company identity. Format is [name]/[version]. like &#39;Sicom/1.0&#39; (optional)</param>
 /// <param name="authorization">The access token. Format is [type] [credentials]. like &#39;Bearer $101$gkeikcha3&#39; (optional)</param>
 /// <returns></returns>
 public void PostMenuListView(StoreMenu payload, string userAgent = null, string authorization = null)
 {
     PostMenuListViewWithHttpInfo(payload, userAgent, authorization);
 }