示例#1
0
        public async Task <IActionResult> Create(AllowanceDetailViewModel allowanceDetail)
        {
            if (ModelState.IsValid)
            {
                AllowanceDetail def = new AllowanceDetail()
                {
                    Month           = allowanceDetail.Month,
                    Year            = allowanceDetail.Year,
                    AllowanceTypeId = allowanceDetail.AllowanceTypeId,
                    EmployeeInfoId  = allowanceDetail.EmployeeInfoId
                };
                //_context.Add(allowanceDetail);
                //await _context.SaveChangesAsync();
                //  AllowanceDetail ss = detailRepository.ffff(allowanceDetail.Month, allowanceDetail.Year, allowanceDetail.EmployeeInfoId, allowanceDetail.AllowanceTypeId);
                //if (ss == null)
                //{
                await detailRepository.Save(def);

                return(RedirectToAction(nameof(Index)));
                //}
                //else
                //{
                //    ViewBag.Message = "This Allowance Type is already pay.";
                //}
            }
            ViewData["AllowanceTypeId"] = new SelectList(allowanceRepository.GetAllowanceList(), "Id", "Name", allowanceDetail.AllowanceTypeId);
            ViewData["EmployeeInfoId"]  = new SelectList(employeeInfoRepository.GetEmployeeInfoList(), "Id", "EmployeeName", allowanceDetail.EmployeeInfoId);
            return(View(allowanceDetail));
        }
示例#2
0
        public async Task <IActionResult> Create([Bind("Id,Month,Year,AllowanceTypeId,EmployeeInfoId")] AllowanceDetailViewModel allowanceDetail)
        {
            if (ModelState.IsValid)
            {
                AllowanceDetail def = new AllowanceDetail()
                {
                    Month           = allowanceDetail.Month,
                    Year            = allowanceDetail.Year,
                    AllowanceTypeId = allowanceDetail.AllowanceTypeId,
                    EmployeeInfoId  = allowanceDetail.EmployeeInfoId
                };
                //_context.Add(allowanceDetail);
                //await _context.SaveChangesAsync();
                await detailRepository.Save(def);

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AllowanceTypeId"] = new SelectList(allowanceRepository.GetAllowanceList(), "Id", "Id", allowanceDetail.AllowanceTypeId);
            ViewData["EmployeeInfoId"]  = new SelectList(employeeInfoRepository.GetEmployeeInfoList(), "Id", "Id", allowanceDetail.EmployeeInfoId);
            return(View(allowanceDetail));
        }