public async Task <ActionResult> UpdateProfileHeThong(HeThongModel model) { if (!ModelState.IsValid) { TempData["Error"] = "Vui lòng kiểm tra lại thông tin."; return(RedirectToRoute("ManagerUserHethong")); } var _hethong = await db.HeThongs.FindAsync(model.HethongId); if (_hethong != null) { if (new UserManager().IsEmailExist(model.Email) && _hethong.Email != model.Email) { TempData["Error"] = "Địa chỉ email đã được sử dụng."; return(RedirectToRoute("ManagerUserHethong")); } _hethong.Email = model.Email ?? null; _hethong.AnhIcon = model.AnhIcon ?? null; _hethong.Picture_GP_KD = model.Picture_GP_KD != null ? "http://" + Request.Url.Host + model.Picture_GP_KD : null; _hethong.Country = model.Country ?? null; _hethong.TenHeThong = model.TenHeThong ?? null; _hethong.SDT = model.SDT ?? null; _hethong.LoaiHinhKD = model.LoaiHinhKD ?? null; db.Entry(_hethong).State = EntityState.Modified; await db.SaveChangesAsync(); if (User.Identity.Name.ToString() != _hethong.Email) { HttpContext.GetOwinContext().Authentication.SignOut(DefaultAuthenticationTypes.ApplicationCookie); return(RedirectToRoute("LoginAccount")); } TempData["Updated"] = "Cập nhật thông tin hệ thống thành công"; return(RedirectToRoute("ManagerUserHethong")); } return(View()); }
public ActionResult ManagerHethong() { var _hethong = db.HeThongs.Where(x => x.Email == User.Identity.Name).FirstOrDefault(); if (_hethong == null) { HttpContext.GetOwinContext().Authentication.SignOut(DefaultAuthenticationTypes.ApplicationCookie); return(RedirectToRoute("LoginAccount")); } var getHeThong = new HeThongModel() { HethongId = _hethong.HeThongId, Email = _hethong.Email, Country = _hethong.Country, AnhIcon = _hethong.AnhIcon, Picture_GP_KD = _hethong.Picture_GP_KD, TenHeThong = _hethong.TenHeThong, SDT = _hethong.SDT, LoaiHinhKD = _hethong.LoaiHinhKD }; ViewBag.lstLoaiHinhKinhDoanh = ListLoaiHinhKD(); return(View(getHeThong)); }