예제 #1
0
        public async Task <IActionResult> Create([Bind("MsPT,NgayThu,SoTien")] Phieuthu phieuthu)
        {
            if (ModelState.IsValid)
            {
                _context.Add(phieuthu);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(phieuthu));
        }
예제 #2
0
        public async Task <IActionResult> CreateKHPT([Bind("MsKH,MsPT,NgayThu,SoTien")] KhachhangPhieuthu KHPT)
        {
            if (ModelState.IsValid)
            {
                Phieuthu phieuthu = new Phieuthu();
                phieuthu.MsPT    = KHPT.MsPT;
                phieuthu.NgayThu = KHPT.NgayThu;
                phieuthu.SoTien  = KHPT.SoTien;
                var khachhang = await _context.KhachHang
                                .FirstOrDefaultAsync(m => m.MsKH == KHPT.MsKH);

                if (khachhang == null)
                {
                    return(NotFound());
                }
                phieuthu.Khachhang = khachhang;
                _context.Add(phieuthu);
                await _context.SaveChangesAsync();
            }
            return(RedirectToAction("Details", new RouteValueDictionary(new { controller = "KhachHang", action = "Details", id = KHPT.MsKH })));
        }