public ActionResult Create([Bind(Include = "ID,PhamNhanID,NgayChuaTri")] Benh benh) { if (ModelState.IsValid) { benh.NgayBatDauChuaTri = DateTime.Now.AddDays(1); db.Benh.Add(benh); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(benh)); }
// GET: Benhs/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Benh benh = db.Benhs.Find(id); if (benh == null) { return(HttpNotFound()); } return(View(benh)); }
public JsonResult ConfirmThemLoaiBenh(string TenBenh) { int newIDLoaiBenh = 0; if (TenBenh != null) { Benh benh = new Benh(); benh.TenBenh = TenBenh; db.Benhs.Add(benh); db.SaveChanges(); newIDLoaiBenh = benh.ID_Benh; } return(Json(newIDLoaiBenh, JsonRequestBehavior.AllowGet)); }
// GET: Benhs/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Benh benh = db.Benh.Find(id); if (benh == null) { return(HttpNotFound()); } ViewBag.PhamNhanID = new SelectList(db.PhamNhan, "ID", "TenPhamNhan", benh.PhamNhanID); return(View(benh)); }
public bool Create(BenhDTO benhDto) { try { var item = CheckExistsTenbenh(benhDto.TenBenh); if (item) { return(false); } var benh = new Benh { MaBenh = Guid.NewGuid(), TenBenh = benhDto.TenBenh, NguyenNhan = benhDto.NguyenNhan, CachDieuTri = benhDto.CachDieuTri, MoTa = benhDto.MoTa, HinhAnh = benhDto.HinhAnh, }; _benhRepository.Insert(benh); _unitOfWork.Commit(); if (benhDto.MaThuocs != null) { foreach (var mathuoc in benhDto.MaThuocs) { var thuocdieutri = new ThuocDieuTri { MaBenh = benh.MaBenh, MaThuoc = new Guid(mathuoc), }; _unitOfWork.Commit(); } } return(true); } catch (Exception e) { return(false); } }
public void Insert(Benh entity) { unitOfWork.Benhs.Insert(entity); unitOfWork.Complete(); }
public void Delete(Benh entity) { unitOfWork.Benhs.Delete(entity); unitOfWork.Complete(); }
public bool InsertAll(BenhDTO userRoleDataPopups) { var item = CheckExistsTenbenh(userRoleDataPopups.TenBenh); if (item) { return(false); } var benh = new Benh { MaBenh = Guid.NewGuid(), TenBenh = userRoleDataPopups.TenBenh, NguyenNhan = userRoleDataPopups.NguyenNhan, CachDieuTri = userRoleDataPopups.CachDieuTri, MoTa = userRoleDataPopups.MoTa, HinhAnh = userRoleDataPopups.HinhAnh, }; _benhRepository.Insert(benh); _unitOfWork.Commit(); if (userRoleDataPopups.MaThuocs != null) { foreach (var mathuoc in userRoleDataPopups.MaThuocs) { var thuocdieutri = new ThuocDieuTri { MaBenh = benh.MaBenh, MaThuoc = new Guid(mathuoc) }; _thuocdieutriRepository.Insert(thuocdieutri); } _unitOfWork.Commit(); } if (userRoleDataPopups.MaTrieuChungs != null) { foreach (var matrieuchung in userRoleDataPopups.MaTrieuChungs) { var trieuchungbenh = new TrieuChungBenh { MaBenh = benh.MaBenh, MaTrieuChung = new Guid(matrieuchung) }; _trieuchungbenhRepository.Insert(trieuchungbenh); } _unitOfWork.Commit(); } // liệu trình //if (userRoleDataPopups.ListLieuTrinhs.Count <= 0) //{ // return true; //} ////insert new record //for (int i = 0; i < userRoleDataPopups.ListLieuTrinhs.Count; i++) //{ // var roleViewModel = userRoleDataPopups.ListLieuTrinhs[i]; // //if (LieuTrinhConstant.MaLieuTrinh_Empty.Equals(roleViewModel.MaLieuTrinh.ToString())) // //{ // roleViewModel.MaBenh = benh.MaBenh; // roleViewModel.MaLieuTrinh = Guid.NewGuid(); // // continue; // //} // var lstLieuTrinhs = _lieutrinhRepository.GetAll() // .Where(p => p.MaLieuTrinh == roleViewModel.MaLieuTrinh && p.MaBenh == roleViewModel.MaBenh).ToList(); // LieuTrinh LieuTrinh = null; // switch (lstLieuTrinhs.Count) // { // case 0: // LieuTrinh = new LieuTrinh // { // MaBenh = roleViewModel.MaBenh, // MaLieuTrinh = roleViewModel.MaLieuTrinh, // TenLieuTrinh = roleViewModel.TenLieuTrinh, // MoTaLieuTrinh = roleViewModel.MoTaLieuTrinh // }; // _lieutrinhRepository.Insert(LieuTrinh); // break; // default: // LieuTrinh = lstLieuTrinhs[0]; // _lieutrinhRepository.Update(LieuTrinh); // break; // } //} // delete record // DeleteRecord(userId, lstData); // _unitOfWork.Commit(); return(true); }