Esempio n. 1
0
        public ActionResult Create(IncomeViewModel incomeVM)
        {
            if (!ModelState.IsValid)
            {
                return(View(incomeVM));
            }
            incomeVM.EventArgument        = EventArgumentEnum.Create;
            incomeVM.Entity.Paycheck.Date = Convert.ToDateTime(incomeVM.Date);
            incomeVM.Entity.AutoTransferPaycheckContributions = incomeVM.AutoTransferPaycheckContributions;
            if (incomeVM.HandleRequest())
            {
                return(RedirectToAction("Index"));
            }

            return(View(incomeVM));


            //var newSalary = new Salary()
            //{
            //    NetIncome = salary.NetIncome,
            //    PayFrequency = salary.PayFrequency,
            //    Payee = salary.Payee,
            //    GrossPay = salary.GrossPay,
            //    PayTypesEnum = salary.PayTypesEnum
            //};

            //_db.Salaries.Add(newSalary);
            //_db.SaveChanges();
        }
Esempio n. 2
0
        // GET: Salary/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            IncomeViewModel incomeVM = new IncomeViewModel();

            incomeVM.EventArgument      = EventArgumentEnum.Delete;
            incomeVM.EventCommand       = EventCommandEnum.Get;
            incomeVM.Entity.Paycheck.Id = (int)id;
            if (incomeVM.HandleRequest())
            {
                return(View(incomeVM));
            }


            return(HttpNotFound());

            //if (salary == null)
            //{
            //    return HttpNotFound();
            //}
            //return View(salary);
        }
Esempio n. 3
0
        //private readonly ApplicationDbContext _db = new ApplicationDbContext();

        // GET: Salary
        public ActionResult Index()
        {
            IncomeViewModel incomeVM = new IncomeViewModel();

            incomeVM.EventArgument = EventArgumentEnum.Read;
            incomeVM.EventCommand  = EventCommandEnum.Get;
            incomeVM.HandleRequest();
            return(View(incomeVM));
        }
Esempio n. 4
0
        public ActionResult DeleteConfirmed(int id)
        {
            IncomeViewModel incomeVM = new IncomeViewModel();

            incomeVM.EventArgument      = EventArgumentEnum.Delete;
            incomeVM.EventCommand       = EventCommandEnum.Delete;
            incomeVM.Entity.Paycheck.Id = id;
            incomeVM.HandleRequest();
            //Salary salary = _db.Salaries.Find(id);
            //_db.Salaries.Remove(salary);
            //_db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 5
0
        public ActionResult Edit(IncomeViewModel incomeVM)
        {
            if (!ModelState.IsValid)
            {
                return(View(incomeVM));
            }
            incomeVM.EventArgument = EventArgumentEnum.Update;
            incomeVM.EventCommand  = EventCommandEnum.Edit;
            if (incomeVM.HandleRequest())
            {
                return(RedirectToAction("Index"));
            }


            return(View(incomeVM));
            //_db.Entry(salary).State = EntityState.Modified;
            //_db.SaveChanges();
        }
Esempio n. 6
0
        // GET: Salary/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            IncomeViewModel incomeVM = new IncomeViewModel();

            incomeVM.EventArgument = EventArgumentEnum.Read;
            incomeVM.EventCommand  = EventCommandEnum.Details;
            incomeVM.HandleRequest();

            //Salary salary = _db.Salaries.Find(id);
            //if (salary == null)
            //{
            //    return HttpNotFound();
            //}
            return(View(incomeVM));
        }
Esempio n. 7
0
        // GET: Salary/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            IncomeViewModel incomeVM = new IncomeViewModel();

            incomeVM.EventArgument      = EventArgumentEnum.Update;
            incomeVM.EventCommand       = EventCommandEnum.Get;
            incomeVM.Entity.Paycheck.Id = (int)id;
            incomeVM.HandleRequest();
            if (incomeVM.Entity.Paycheck == null)
            {
                return(HttpNotFound());
            }


            return(View(incomeVM));
        }