public async Task <IActionResult> Create([Bind("Id,FkChuyenKhoa,FkBacSi,NgayHen,FkGioHen,MoTaTrieuChung,NgayGui,DiaChiEmail,HoVaTen,FkNamSinh,GioiTinh,FkTinhTrangHonNhan,FkQuocTich,SoDienThoaiNha,SoDienThoaiDiDong,DiaChi,BacSi,FkTrangThai")] HenKhamBenh henKhamBenh) { if (ModelState.IsValid) { var listChuyenKhoa = await GetListChuyenKhoaAsync(); ViewBag.ListChuyenKhoa = listChuyenKhoa; var listBacSi = await GetListBacSiAsync(); ViewBag.ListBacSi = listBacSi; var listGioHen = await GetListGioHenAsync(); ViewBag.ListGioHen = listGioHen; var listNamSinh = await GetListNamSinhAsync(); ViewBag.ListNamSinh = listNamSinh; var listTinhTrangHonNhan = await GetListTinhTrangHonNhanAsync(); ViewBag.ListTinhTrangHonNhan = listTinhTrangHonNhan; var listTrangThai = await GetListTrangThaiAsync(); ViewBag.ListTrangThai = listTrangThai; var listQuocTich = await GetListQuocTichAsync(); ViewBag.ListQuocTich = listQuocTich; InitParam.Db.Add(henKhamBenh); await InitParam.Db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["FkBacSi"] = new SelectList(InitParam.Db.DanhMucBacSi, "Id", "Id", henKhamBenh.FkBacSi); ViewData["FkChuyenKhoa"] = new SelectList(InitParam.Db.PhongKham, "Id", "Id", henKhamBenh.FkChuyenKhoa); ViewData["FkGioHen"] = new SelectList(InitParam.Db.GioKham, "Id", "Id", henKhamBenh.FkGioHen); ViewData["FkNamSinh"] = new SelectList(InitParam.Db.NamSinh, "Id", "Id", henKhamBenh.FkNamSinh); ViewData["FkQuocTich"] = new SelectList(InitParam.Db.QuocTich, "Id", "Id", henKhamBenh.FkQuocTich); ViewData["FkTinhTrangHonNhan"] = new SelectList(InitParam.Db.TinhTrangHonNhan, "Id", "Id", henKhamBenh.FkTinhTrangHonNhan); ViewData["FkTrangThai"] = new SelectList(InitParam.Db.TrangThai, "Id", "Id", henKhamBenh.FkTrangThai); return(View(henKhamBenh)); }
public async Task <IActionResult> Create(HenKhamBenhCreateViewModel model) { ViewBag.ListGioHen = ListGioHen; ViewBag.ListChuyenKhoa = ListChuyenKhoa; ViewBag.ListNamSinh = ListNamSinh; ViewBag.ListTinhTrangHonNhan = ListTinhTrangHonNhan; ViewBag.ListTrangThai = ListTrangThai; if (!ModelState.IsValid) { return(View(model)); } var dbItem = new HenKhamBenh(); dbItem.HoVaTen = model.HoVaTen; dbItem.DiaChi = model.DiaChi; dbItem.SoDienThoaiDiDong = model.SoDienThoaiDiDong; dbItem.SoDienThoaiNha = model.SoDienThoaiNha; dbItem.DiaChiEmail = model.DiaChiEmail; dbItem.FkNamSinh = model.NamSinhId; dbItem.GioiTinh = model.GioiTinh; dbItem.FkChuyenKhoa = model.ChuyenKhoaId; dbItem.NgayHen = model.NgayHen; dbItem.FkGioHen = model.GioHenId; dbItem.FkBacSi = model.BacSiId; dbItem.MoTaTrieuChung = model.MoTaTrieuChung; dbItem.FkTinhTrangHonNhan = model.TinhTrangHonNhanId; dbItem.FkQuocTich = model.QuocTichId; dbItem.FkTrangThai = model.TrangThaiId; dbItem.NgayGui = DateTime.Now; InitParam.Db.HenKhamBenh.Add(dbItem); await InitParam.Db.SaveChangesAsync(); return(RedirectToAction(nameof(Edit), new { id = dbItem.Id })); }
public async Task <IActionResult> Index(HenKhamBenh henKhamBenh) { if (ModelState.IsValid) { InitParam.Db.Add(henKhamBenh); await InitParam.Db.SaveChangesAsync(); RedirectToAction(nameof(Index)); } var listPhongKham = await GetPhongKhamAsync(); var listGioKham = await GetGioKhamAsync(); var listNamSinh = await GetNamSinhAsync(); var listBacSi = await GetListBacSiAsync(); ViewBag.listPhongKham = listPhongKham; ViewBag.listGioKham = listGioKham; ViewBag.listNamSinh = listNamSinh; ViewBag.listBacSi = listBacSi; return(View(henKhamBenh)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,FkChuyenKhoa,FkBacSi,NgayHen,FkGioHen,MoTaTrieuChung,NgayGui,DiaChiEmail,HoVaTen,FkNamSinh,GioiTinh,FkTinhTrangHonNhan,FkQuocTich,SoDienThoaiNha,SoDienThoaiDiDong,DiaChi,BacSi,FkTrangThai")] HenKhamBenh henKhamBenh) { if (id != henKhamBenh.Id) { return(NotFound()); } if (ModelState.IsValid) { try { InitParam.Db.Update(henKhamBenh); await InitParam.Db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HenKhamBenhExists(henKhamBenh.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["FkBacSi"] = new SelectList(InitParam.Db.DanhMucBacSi, "Id", "Id", henKhamBenh.FkBacSi); ViewData["FkChuyenKhoa"] = new SelectList(InitParam.Db.PhongKham, "Id", "Id", henKhamBenh.FkChuyenKhoa); ViewData["FkGioHen"] = new SelectList(InitParam.Db.GioKham, "Id", "Id", henKhamBenh.FkGioHen); ViewData["FkNamSinh"] = new SelectList(InitParam.Db.NamSinh, "Id", "Id", henKhamBenh.FkNamSinh); ViewData["FkQuocTich"] = new SelectList(InitParam.Db.QuocTich, "Id", "Id", henKhamBenh.FkQuocTich); ViewData["FkTinhTrangHonNhan"] = new SelectList(InitParam.Db.TinhTrangHonNhan, "Id", "Id", henKhamBenh.FkTinhTrangHonNhan); ViewData["FkTrangThai"] = new SelectList(InitParam.Db.TrangThai, "Id", "Id", henKhamBenh.FkTrangThai); return(View(henKhamBenh)); }