Advertisement
Guest User

My20486_03_CalcMVC.Controllers

a guest
Mar 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.49 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using My20486_03_CalcMVC.Models;
  7.  
  8. namespace My20486_03_CalcMVC.Controllers
  9. {
  10.     public class CalcController : Controller
  11.     {
  12.         //
  13.         // GET: /Calc/
  14.         //just for demo!
  15.         public ActionResult _Index()
  16.         {
  17.             double x=0, y=0;
  18.             string operation = "";
  19.             Calc1 calc1 = new Calc1();
  20.             if (Request["x"] != null)
  21.             {
  22.                 operation = Request["operation"];
  23.                 x = double.Parse(Request["x"]);
  24.                 y = double.Parse(Request["y"]);
  25.             }
  26.             calc1.X = x;
  27.             calc1.Y = y;
  28.             calc1.Operation = operation;
  29.             //calc1.Plus();
  30.             calc1.DoCalc();
  31.  
  32.             return View(calc1);
  33.         }
  34.         public ActionResult Index()
  35.         {
  36.             Calc1 calc1 = new Calc1();
  37.             calc1.DoCalc();
  38.             return View(calc1);
  39.         }
  40.         public ActionResult DoCalc(double x, double y, string operation)
  41.         {
  42.             Calc1 calc1 = new Calc1();
  43.             calc1.X = x;
  44.             calc1.Y = y;
  45.             calc1.Operation = operation;
  46.             calc1.DoCalc();
  47.  
  48.             return View("Index", calc1);
  49.         }
  50.        
  51.         [HttpPost]
  52.         public ActionResult DoCalc(Calc1 calc1)
  53.         {
  54.             calc1.DoCalc();
  55.             return View("Index", calc1);
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement