コード例 #1
0
        public IActionResult SetFee(AccMngViewModel amvm)
        {
            var i = _context.Class.ToList();

            i.Insert(0, new Class {
                ClassId = 0, ClassName = "Select the class"
            });
            ViewBag.Class = i;
            if (amvm.classidVM == 0)
            {
                ViewBag.msg1 = "Please Choose a Class";
                return(View());
            }

            AccountsManagement am = new AccountsManagement();

            am.FeeAmount = amvm.feeamountVM;
            am.ClassId   = amvm.classidVM;
            var v = _context.AccountsManagement.Where(q => q.ClassId == amvm.classidVM).FirstOrDefault();

            if (v != null)
            {
                ViewBag.msg2 = "Fee is already set for this class!";
                return(View());
            }
            _context.AccountsManagement.Add(am);
            _context.SaveChanges();
            ModelState.Clear();

            return(View());
        }
コード例 #2
0
        public IActionResult UpdateFeeList(AccMngViewModel updt)
        {
            //var i = _context.Class.ToList();
            //i.Insert(0, new Class { ClassId = 0, ClassName = "Select the class" });
            //ViewBag.Class = i;
            //if (updt.classidVM == 0)
            //{
            //    ViewBag.msg = "Please Select a Class";
            //    return View();
            //}
            AccountsManagement am = new AccountsManagement();

            am.ClassId              = updt.classidVM;
            am.FeeAmount            = updt.feeamountVM;
            am.AccountsManagementId = updt.PrimaryKey;
            _context.AccountsManagement.Update(am);
            _context.SaveChanges();
            ModelState.Clear();
            return(RedirectToAction("FeeList"));
        }