public async Task <IActionResult> Edit(int id, QuanTrac requestData) { if (id != requestData.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(requestData); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!QuanTracExists(requestData.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(requestData)); }
public async Task <IActionResult> Create(ToTrinhDto requestData) { if (requestData.MaToChuc <= 0 || requestData.MaDonViHanhChinh <= 0) { throw new Exception(); } if (ModelState.IsValid) { // Tạo mẫu quan trắc var quanTrac = new QuanTrac() { MucNuocDong = requestData.MucNuocDong, MucNuocTinh = requestData.MucNuocTinh, LuuLuong = requestData.LuuLuongNuoc, ChatLuongNuoc = requestData.ChatLuongNuoc }; _context.Add(quanTrac); await _context.SaveChangesAsync(); // Tạo tờ trình requestData.NgayTao = DateTime.Now; requestData.MaQuanTrac = quanTrac.Id; var model = this.mapper.Map <ToTrinh>(requestData); _context.Add(model); await _context.SaveChangesAsync(); return(Redirect("/ToTrinh/Index")); } return(View(requestData)); }
public async Task <IActionResult> Create(QuanTrac requestData) { if (ModelState.IsValid) { _context.Add(requestData); await _context.SaveChangesAsync(); return(Redirect("/QuanTrac/Index")); } return(View(requestData)); }