public ActionResult UpdateStatus(long?id, short?status) { Common.MessageComment message = new Common.MessageComment() { Status = false, Message = string.Empty }; if (IsLogin()) { if (ModelState.IsValid) { var tblComment = db.tblComments.Find(id); tblComment.Status = status ?? 0; db.Entry(tblComment).State = EntityState.Modified; message.Status = db.SaveChanges() > 0; message.Message = message.Status == true ? "Hành động thành công!" : "Hành động thất bại!"; } message.Message = "Hành động thất bại!"; } else { message.Message = "Bạn không có quền thực hiện hành động này!"; RedirectToAction("Login", "User"); } return(Json(message, JsonRequestBehavior.AllowGet)); }
public ActionResult Edit([Bind(Include = "id,code,category_id,name,slug,overview,image,description,detail,price,unit,sale,star,is_stock,is_active,created_at")] Product product, HttpPostedFileBase imageFile) { if (imageFile != null && imageFile.ContentLength > 0) { if (product.image != null) { string filePathOld = Path.Combine(Server.MapPath("~/Images"), product.image); System.IO.File.Delete(filePathOld); } string fileName = Path.GetFileNameWithoutExtension(imageFile.FileName); string extension = Path.GetExtension(imageFile.FileName); string filePathNew = Path.Combine(Server.MapPath("~/Images"), fileName); filePathNew = filePathNew + extension; imageFile.SaveAs(filePathNew); product.image = fileName + extension; } if (ModelState.IsValid) { db.Entry(product).State = EntityState.Modified; if (imageFile == null) { db.Entry(product).Property(m => m.image).IsModified = false; } db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.category_id = new SelectList(db.Categories, "id", "name", product.category_id); return(View(product)); }
public ActionResult Edit(int id, DOCGIA dOCGIA, HttpPostedFileBase uploadImage) { try { if (uploadImage != null && uploadImage.ContentLength > 0) { if (dOCGIA.IMAGE != null) { string filePathOld = Path.Combine(Server.MapPath("~/Images"), dOCGIA.IMAGE); System.IO.File.Delete(filePathOld); } string fileName = Path.GetFileNameWithoutExtension(uploadImage.FileName); string extension = Path.GetExtension(uploadImage.FileName); string filePathNew = Path.Combine(Server.MapPath("~/Images"), fileName); filePathNew = filePathNew + extension; uploadImage.SaveAs(filePathNew); dOCGIA.IMAGE = fileName + extension; } using (ModelDbContext modelDbContext = new ModelDbContext()) { modelDbContext.Entry(dOCGIA).State = EntityState.Modified; if (uploadImage == null) { modelDbContext.Entry(dOCGIA).Property(m => m.IMAGE).IsModified = false; } modelDbContext.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit([Bind(Include = "IDBenhNhan,HoTen,GioiTinh,NamSinh,Email,DienThoai,DiaChi,CMND,TaiKhoan,MatKhau,Role")] BenhNhan benhNhan) { if (ModelState.IsValid) { db.Entry(benhNhan).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(benhNhan)); }
public ActionResult Edit([Bind(Include = "MaChuDe,TenChuDe")] ChuDe chuDe) { if (ModelState.IsValid) { db.Entry(chuDe).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(chuDe)); }
public ActionResult Edit([Bind(Include = "IDTinTuc,TieuDe,NoiDung,MoTa,img,NgayDang")] TinTuc tinTuc) { if (ModelState.IsValid) { db.Entry(tinTuc).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tinTuc)); }
public ActionResult Edit([Bind(Include = "IDDichBenh,TenDich,PhamVi,SoCaMac,TuVong,DaKhoi,NgCapNhap")] DichBenh dichBenh) { if (ModelState.IsValid) { db.Entry(dichBenh).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(dichBenh)); }
public ActionResult Edit([Bind(Include = "id,name,phone,address,membership,email,created_at,username,password,status")] Customer customer) { if (ModelState.IsValid) { db.Entry(customer).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customer)); }
public ActionResult Edit([Bind(Include = "MaNXB,TenNXB,DiaChi,DienThoai")] NhaXuatBan nhaXuatBan) { if (ModelState.IsValid) { db.Entry(nhaXuatBan).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(nhaXuatBan)); }
public ActionResult Edit([Bind(Include = "IDKhoa,TenKhoa")] Khoa khoa) { if (ModelState.IsValid) { db.Entry(khoa).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(khoa)); }
public ActionResult Edit([Bind(Include = "id,code,name,slug,description,created_at")] Category category) { if (ModelState.IsValid) { db.Entry(category).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(category)); }
public ActionResult Edit([Bind(Include = "IDTrungTam,TenTrungTam,DiaChi,IDTinh")] TrungTamYTe trungTamYTe) { if (ModelState.IsValid) { db.Entry(trungTamYTe).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.IDTinh = new SelectList(db.Tinhs, "IDTinh", "TenTinh", trungTamYTe.IDTinh); return(View(trungTamYTe)); }
public ActionResult Edit([Bind(Include = "IDThongBao,NoiDung,IDBenhNhan,NgThongBao")] ThongBao thongBao) { if (ModelState.IsValid) { db.Entry(thongBao).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.IDBenhNhan = new SelectList(db.BenhNhans, "IDBenhNhan", "HoTen", thongBao.IDBenhNhan); return(View(thongBao)); }
public ActionResult Edit([Bind(Include = "IDBacsi,HoTen,Email,DienThoai,TaiKhoan,MatKhau,IDKhoa,Role")] Bacsi bacsi) { if (ModelState.IsValid) { db.Entry(bacsi).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.IDKhoa = new SelectList(db.Khoas, "IDKhoa", "TenKhoa", bacsi.IDKhoa); return(View(bacsi)); }
public ActionResult Edit([Bind(Include = "IDCauHoi,IDBenhNhan,CauHoi,TraLoi,NgayHoi")] HoiDap hoiDap) { if (ModelState.IsValid) { db.Entry(hoiDap).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.IDBenhNhan = new SelectList(db.BenhNhans, "IDBenhNhan", "HoTen", hoiDap.IDBenhNhan); return(View(hoiDap)); }
public ActionResult Edit([Bind(Include = "MaSach,TenSach,GiaBan,MoTa,NgayCapNhat,AnhBia,SoLuongTon,MaChuDe,MaNXB,Moi")] Sach sach) { if (ModelState.IsValid) { db.Entry(sach).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MaChuDe = new SelectList(db.ChuDes, "MaChuDe", "TenChuDe", sach.MaChuDe); ViewBag.MaNXB = new SelectList(db.NhaXuatBans, "MaNXB", "TenNXB", sach.MaNXB); return(View(sach)); }
public ActionResult Edit([Bind(Include = "IDHoSo,IDBenhNhan,IDBacSi,NgayKham,KetQua,GhiChu")] HoSo hoSo) { if (ModelState.IsValid) { db.Entry(hoSo).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.IDBacSi = new SelectList(db.Bacsis, "IDBacsi", "HoTen", hoSo.IDBacSi); ViewBag.IDBenhNhan = new SelectList(db.BenhNhans, "IDBenhNhan", "HoTen", hoSo.IDBenhNhan); return(View(hoSo)); }
public ActionResult Edit([Bind(Include = "id,code,customer_id,staff_id,address,phone,email,total_price,note,status,created_at")] Order order) { if (ModelState.IsValid) { db.Entry(order).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.customer_id = new SelectList(db.Customers, "id", "name", order.customer_id); ViewBag.staff_id = new SelectList(db.Staffs, "id", "name", order.staff_id); return(View(order)); }
public ActionResult Edit([Bind(Include = "IDLich,IDBenhNhan,IDBacSi,BatDau,KetThuc,GhiChu,TrangThai")] LichHen lichHen) { if (ModelState.IsValid) { db.Entry(lichHen).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.IDBacSi = new SelectList(db.Bacsis, "IDBacsi", "HoTen", lichHen.IDBacSi); ViewBag.IDBenhNhan = new SelectList(db.BenhNhans, "IDBenhNhan", "HoTen", lichHen.IDBenhNhan); return(View(lichHen)); }
public ActionResult Edit(int id, TINHTRANGSACH tINHTRANGSACH) { try { db.Entry(tINHTRANGSACH).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit(int id, MUONSACK mUONSACK) { try { using (ModelDbContext modelDbContext = new ModelDbContext()) { modelDbContext.Entry(mUONSACK).State = EntityState.Modified; modelDbContext.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } var user = await _userManager.GetUserAsync(User); if (user == null) { return(NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.")); } var changePasswordResult = await _userManager.ChangePasswordAsync(user, Input.OldPassword, Input.NewPassword); if (!changePasswordResult.Succeeded) { foreach (var error in changePasswordResult.Errors) { ModelState.AddModelError(string.Empty, error.Description); } return(Page()); } else { using (var db = new ModelDbContext()) { var setNewPasswordInOriginalDb = db.Users.Where(x => x.Email == user.Email) .SingleOrDefault(); setNewPasswordInOriginalDb.Password = Input.NewPassword; //db.Update(setNewPasswordInOriginalDb); db.Attach(setNewPasswordInOriginalDb); db.Entry(setNewPasswordInOriginalDb).Property("Password").IsModified = true; var responseSave = await db.SaveChangesAsync(); } } await _signInManager.RefreshSignInAsync(user); _logger.LogInformation("User changed their password successfully."); StatusMessage = "Your password has been changed."; return(RedirectToPage()); }
public ActionResult Edit(int id, THETHUVIEN tHETHUVIEN) { try { using (ModelDbContext db = new ModelDbContext()) { db.Entry(tHETHUVIEN).State = EntityState.Modified; db.SaveChanges(); } // TODO: Add update logic here return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit([Bind(Include = "Id,Group,Titles,Describe,Content,Img,Order,View")] tblNew tblNew) { if (IsLogin()) { if (SessionDecentralize() == (short)NewsProject.Commons.Decentralize.Admin) { if (ModelState.IsValid) { tblNew.ImgResizer = tblNew.Img.Replace("/Uploads", "/Uploads/_thumbs"); tblNew.ModifyDate = DateTime.Now; db.Entry(tblNew).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tblNew)); } return(View("Index")); } else { return(RedirectToAction("Login", "User")); } }
public ActionResult account(Models.UserModel user) { if (ModelState.IsValid) { List <User_Table> getUserData = new List <User_Table>(); int userID = int.Parse(Request.Cookies["uID"].ToString()); using (var db = new ModelDbContext()) { db.Users .Where(x => x.User_Id == userID) .ToList(); foreach (User_Table updateUser in getUserData) { updateUser.First_Name = user.firstName; updateUser.Last_Name = user.lastName; updateUser.Email = user.email; updateUser.Password = user.password; updateUser.phone = user.phone; updateUser.Address = user.address; updateUser.Adress2 = user.address2; updateUser.City = user.city; updateUser.State = user.state; updateUser.Zip = user.zipCode; updateUser.Specialty = user.specialty; updateUser.Degree = user.designation; db.Attach(updateUser); db.Entry(updateUser); } db.SaveChanges(); } ViewData.Add("userId", userID); } return(View(user)); }