public async Task <IActionResult> EditBasicInfo(string id) { IdentityUser usr = await GetCurrentUserAsync(); var user1 = await _userManager.FindByIdAsync(usr.Id); var role1 = await _userManager.GetRolesAsync(user1); string logintypee = role1[0].ToString(); var objfromdb = _db.ApplicationUser.FirstOrDefault(u => u.Id == id); ViewBag.Countries = _unitofWork.country.GetAll().Where(x => x.isdeleted == false).Select(x => new SelectListItem() { Text = x.countryname, Value = x.id.ToString() }); int countryiddd = 0, stateid = 0, countryid = 0; if (objfromdb.cityid != null) { int cityiddd = (int)objfromdb.cityid; // countryiddd = (int)objfromdb.cityid; stateid = _unitofWork.city.Get(cityiddd).stateid; countryid = _unitofWork.state.Get(stateid).countryid; } if (objfromdb == null) { return(NotFound()); } var user = await _userManager.FindByIdAsync(id); var roles = await _userManager.GetRolesAsync(user); var model = new EditBasicInformationModel { Id = objfromdb.Id, name = objfromdb.name, companyName = objfromdb.companyName, businessYear = objfromdb.businessYear, //productDealin = objfromdb.productDealin, multipleproductDealin = objfromdb.productDealin, //ExportToCountries = objfromdb.ExportToCountries, multipleExportToCountries = objfromdb.ExportToCountries, userlatitude = objfromdb.userlatitude, userlongitude = objfromdb.userlongitude, packHouselatitude = objfromdb.packHouselatitude, packHouselongitude = objfromdb.packHouselongitude, packHouseAddress = objfromdb.packHouseAddress, deviceid = objfromdb.deviceid, //countryid = countryid, //stateid = stateid, //cityid = (int)objfromdb.cityid, logoName = objfromdb.logo, Email = objfromdb.Email, phonenumber = objfromdb.PhoneNumber, userType = roles[0].ToString(), loginType = logintypee }; if (objfromdb.cityid != null) { model.countryid = countryid; model.stateid = stateid; model.cityid = (int)objfromdb.cityid; ViewBag.States = _unitofWork.state.GetAll().Where(x => x.isdeleted == false && x.countryid == model.countryid).Select(x => new SelectListItem() { Text = x.StateName, Value = x.id.ToString() }); ViewBag.Cities = _unitofWork.city.GetAll().Where(x => x.isdeleted == false && x.stateid == model.stateid).Select(x => new SelectListItem() { Text = x.cityName, Value = x.id.ToString() }); } return(View(model)); }
public async Task <IActionResult> EditBasicInfo(EditBasicInformationModel model) { if (ModelState.IsValid) { try { var obj = _db.ApplicationUser.FirstOrDefault(u => u.Id == model.Id); if (obj == null) { return(NotFound()); } BasicInformationDtos objBasicInformationDtos = new BasicInformationDtos(); objBasicInformationDtos.Id = model.Id; objBasicInformationDtos.name = model.name; objBasicInformationDtos.companyName = model.companyName; objBasicInformationDtos.cityid = model.cityid; objBasicInformationDtos.businessYear = model.businessYear; objBasicInformationDtos.productDealin = model.multipleproductDealin; objBasicInformationDtos.ExportToCountries = model.multipleExportToCountries; objBasicInformationDtos.userlatitude = model.userlatitude; objBasicInformationDtos.userlongitude = model.userlongitude; objBasicInformationDtos.packHouselatitude = model.packHouselatitude; objBasicInformationDtos.packHouselongitude = model.packHouselongitude; objBasicInformationDtos.packHouseAddress = model.packHouseAddress; objBasicInformationDtos.isBasicInfoFill = true; if (model.logo != null && model.logo.Length > 0) { using (var ms = new MemoryStream()) { model.logo.CopyTo(ms); var fileBytes = ms.ToArray(); string s = Convert.ToBase64String(fileBytes); objBasicInformationDtos.logo = s; ms.Close(); // act on the Base64 data } } else { objBasicInformationDtos.logo = null; } string path1 = SD.APIBaseUrl + "user/UpdateBasicInformation"; // var datalist = await _mainCategoryRepository.GetAllAsync(SD.APIBaseUrl + "Maincategory/GetMainCategory"); bool res = await _userRegistrationAPIRepository.UpdateAsync(path1, objBasicInformationDtos); if (res) { TempData["success"] = "Record Update successfully"; } else { TempData["error"] = "Record Not Update"; } //if(model.userType== "Admin") if (model.loginType == "Admin") { return(RedirectToAction(nameof(Index))); } else { return(RedirectToAction("Profile", "UserLogin", new { area = "Admin", id = model.Id })); } } catch { } return(RedirectToAction(nameof(Index))); } else { ViewBag.Countries = _unitofWork.country.GetAll().Where(x => x.isdeleted == false).Select(x => new SelectListItem() { Text = x.countryname, Value = x.id.ToString() }); int countryiddd = 0, stateid = 0, countryid = 0; if (model.cityid != null) { int cityiddd = (int)model.cityid; // countryiddd = (int)objfromdb.cityid; stateid = _unitofWork.city.Get(cityiddd).stateid; countryid = _unitofWork.state.Get(stateid).countryid; } ViewBag.States = _unitofWork.state.GetAll().Where(x => x.isdeleted == false && x.countryid == model.countryid).Select(x => new SelectListItem() { Text = x.StateName, Value = x.id.ToString() }); ViewBag.Cities = _unitofWork.city.GetAll().Where(x => x.isdeleted == false && x.stateid == model.stateid).Select(x => new SelectListItem() { Text = x.cityName, Value = x.id.ToString() }); return(View(model)); } }