示例#1
0
        public ActionResult Index(UserCalcViewModel model, FormCollection formCollection)
        {
            try
            {
                if (formCollection.Count >= 2)
                {
                    model.Input = formCollection[1].ToString();
                    if (!string.IsNullOrEmpty(model.Input))
                    {
                        model.IpAddress = Request.UserHostAddress;
                        model           = service.Caltulate(model).GetAwaiter().GetResult();
                        model.Input     = string.Empty;
                    }
                }

                if (formCollection.Count == 1)
                {
                    var strId = formCollection.Keys[0].ToString();
                    var id    = long.Parse(strId);
                    model.IpAddress = Request.UserHostAddress;
                    model.RepeatId  = id;
                    model           = service.GetCalcById(model).GetAwaiter().GetResult();
                }
                return(View(model));
            }
            catch
            {
                model.Message   = "Введенные данные не являются математической формулой";
                model.IpAddress = Request.UserHostAddress;
                service.GetUserHistory(model).GetAwaiter().GetResult();
                return(View(model));
            }
        }