Exemplo n.º 1
0
        public ActionResult CreateEmployee(Employee emp)
        {
            EmployeeBusinessLayer ebl = new EmployeeBusinessLayer();

            ebl.Add(emp);
            return(RedirectToAction("index"));
        }
Exemplo n.º 2
0
        public ActionResult Save(Employee emp)
        {
            EmployeeBusinessLayer ebl = new EmployeeBusinessLayer();

            ebl.Add(emp);
            return(new RedirectResult("index"));
        }
Exemplo n.º 3
0
        public ActionResult CreateEmployee(Employee e, string BtnSubmit)
        {
            switch (BtnSubmit)
            {
            //case "保存":
            //    return Content("姓名:" + e.Name + ",工资:" + e.Salary);
            //case "取消":
            //    return RedirectToAction("Index");
            case "保存":
            {
                if (ModelState.IsValid)
                {
                    EmployeeBusinessLayer empBal = new EmployeeBusinessLayer();
                    //empBal.SaveEmployee(e);
                    empBal.Add(e);
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View("CreateEmployee"));
                }
            }

            case "取消":
                return(RedirectToAction("Index"));
            }
            return(new EmptyResult());
            //return (e.Name + e.Salary);
            //return new RedirectResult("Index");
        }
Exemplo n.º 4
0
        public ActionResult Save(Employee emp)
        {
            //string name=emp.Name;
            //int salary=emp.Salary;
            EmployeeBusinessLayer eve = new EmployeeBusinessLayer();

            eve.Add(emp);
            return(new RedirectResult("index"));
        }
Exemplo n.º 5
0
        public async Task <IHttpActionResult> Create(EmployeeViewModel user)
        {
            var     empBal = new EmployeeBusinessLayer();
            decimal salary = 0;

            decimal.TryParse(user.Salary, out salary);
            await empBal.Add(new Employee
            {
                Name   = user.Name,
                Salary = salary
            });

            return(Created("api/User/" + user.Name, user));
        }
Exemplo n.º 6
0
        public ActionResult Save(EmployeeViewModel e, string BtnSubmit)
        {
            switch (BtnSubmit)
            {
            case "Save Employee":
                if (ModelState.IsValid)
                {
                    decimal salary = 0;
                    decimal.TryParse(e.Salary, out salary);
                    Task.Run(async() =>
                    {
                        var empBal = new EmployeeBusinessLayer();
                        await empBal.Add(new Employee
                        {
                            Name   = e.Name,
                            Salary = salary
                        });
                    });

                    return(RedirectToAction("Index"));
                }
                else
                {
                    var evm = new EmployeeViewModel
                    {
                        //FooterData = new FooterViewModel()
                        //{
                        //    CompanyName = "Ryan's New Company",
                        //    Year = DateTime.Now.Year.ToString()
                        //},
                        UserName = "******"
                    };
                    return(RedirectToAction("Add", evm));
                }

            default:
                return(RedirectToAction("Index"));
            }
        }