public JsonResult Add(User user, int role, string roleDescription) { userService.Add(user); //userService.Save(); ShopUser shopUser = new ShopUser(); //(int)shopUserService.GetByID(3):số 3 sẽ được thay bằng userID đang đăng nhập khi bổ sung Login shopUser = shopUserService.Create((int)shopUserService.GetByID(3).ShopID, user.ID, role, roleDescription); shopUserService.Add(shopUser); shopUserService.Save(); var ward = wardService.GetByID((int)user.WardID); var district = districtService.GetByID(ward.DistrictID); var city = cityService.GetByID(district.CityID); //Lựa chọn trường sẽ trả ra view var data = new { ID = shopUser.ID, Name = user.Name, Username = user.Username, Email = user.Email, DetailAddress = user.DetailAddress, City = city.Name, District = district.Name, Ward = ward.Name, Sex = user.Sex, Role = shopUser.RoleID, }; return(Json(data, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Display combobox Ward /// </summary> /// <param name="WardID"></param> /// <returns></returns> public ActionResult PartialViewListWard(int?WardID) { List <Ward> lstWard; if (WardID == null) { District firstDistrict = districtService.GetAll().FirstOrDefault(); lstWard = wardService.GetByDistrictID(firstDistrict.ID).ToList(); } else { Ward w = wardService.GetByID(WardID.GetValueOrDefault(-1)); District d = districtService.GetByID(w.DistrictID); lstWard = wardService.GetByDistrictID(d.ID).ToList(); ViewBag.WardID = WardID; } return(PartialView(lstWard)); }