/// <summary>
        /// Calculating based on the object properties
        /// </summary>
        /// <param name="calculator">Calculating object</param>
        /// <param name="logs">Previous logs</param>
        /// <returns>View with previous logs</returns>
        public ActionResult Calculator(Models.CalculatorModel calculator = null, string logs = null)
        {
            if (calculator != null)
            {
                if (ModelState.IsValid)
                {
                    if (calculator.SelectedMethod == "Sum")
                    {
                        int res = this.Sum(calculator.X, calculator.Y);
                        ViewBag.logs = logs + $"Дата и время: {DateTime.Now.ToString()}     {calculator.X} + {calculator.Y} = {res} \n";
                    }

                    if (calculator.SelectedMethod == "Prod")
                    {
                        int res = this.Prod(calculator.X, calculator.Y);
                        ViewBag.logs = logs + $"Дата и время: {DateTime.Now.ToString()}     {calculator.X} * {calculator.Y} = {res} \n";
                    }

                    return(this.View());
                }
                else
                {
                    ViewBag.NotValidMessage = "Данные не прошли валидацию";//todo pn строки-сообщения - в ресурсы
                    ViewBag.logs            = logs;
                    return(this.View());
                }
            }

            return(this.View());
        }
Example #2
0
        public ActionResult Products(Models.CalculatorModel calculatorModel)
        {
            var retrieve = new Retrieve <SAPO.CalculatorCategory, SAPO.CalculatorCategory>(new Calculator());
            var products = new List <SAPO.CalculatorCategory>();

            products = retrieve.ListRetreive(new SAPO.CalculatorCategory());
            //var getProduct = new SAPO.GetProduct();
            //if (calculatorModel.Categories.Count > 0)
            //    getProduct.CategoryName = calculatorModel.Categories[0].Name;
            //if (calculatorModel.Brands.Count > 0)
            //    getProduct.BrandIds = calculatorModel.Brands;
            //Retrieve<SAPO.GetProduct, SAPO.ProductsPro> retrieve = new Retrieve<SAPO.GetProduct, SAPO.ProductsPro>(new Products());
            //List<SAPO.ProductsPro> products = new List<SAPO.ProductsPro>();
            //products = retrieve.ListRetreive(getProduct);
            return(Json(products, JsonRequestBehavior.AllowGet));
        }
        // GET: Calculator
        public ActionResult Index()
        {
            var calculatorModel = new Models.CalculatorModel();
            var menu            = new SAPO.MenuRequest();

            menu.IsShowOnCalculator = true;

            var retrieveCategories = new Retrieve <SAPO.MenuRequest, SAPO.Category>(new Categories());

            calculatorModel.Categories = retrieveCategories.ListRetreive(menu);

            var brand         = new SAPO.BrandInput();
            var retrievebrand = new Retrieve <SAPO.BrandInput, SAPO.Brands>(new SmartBAL.Brands());

            calculatorModel.Brands = retrievebrand.ListRetreive(brand);


            return(View(calculatorModel));
        }
 public ActionResult Index(Models.CalculatorModel calculatorModel)
 {
     Session["calculatorModel"] = calculatorModel;
     return(RedirectToAction("ProductList"));
 }