private UserAddress MakeShippingAddress() { var country = new Country() { Name = "France" }; var stateOrProvince = new StateOrProvince { Name = "IDF", Country = country }; var address = new Address { CountryId = 1, AddressLine1 = "115 Rue Marcel", Country = country, StateOrProvince = stateOrProvince, }; var userAddress = new UserAddress { UserId = 1, Address = address }; return(userAddress); }
public IHttpActionResult PutUserAddress(int id, UserAddress userAddress) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != userAddress.UserAddressID) { return BadRequest(); } try { db.UpdateUserAddress(id,userAddress); } catch (DbUpdateConcurrencyException) { if (!UserAddressExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public HttpResponseMessage SetType(RiderReq req) { var riderId = Convert.ToInt32(req.riderId); var tokenStr = req.Token; Token token = CacheHelper.GetRiderToken(tokenStr); if (token == null) { return(ControllerHelper.Instance.JsonResult(400, "token失效")); } if (token.Payload.UserID != riderId) { return(ControllerHelper.Instance.JsonResult(400, "token错误")); } var rider = RiderInfoOper.Instance.GetById(riderId); if (rider.riderType != 2) { if (rider.riderType == 1) { rider.riderType = 0; } else { rider.riderType = 1; } } //var temp = rider.riderType + 1; //rider.riderType = temp > 2 ? 0 : temp; try { var riderHere = new RiderInfo(); riderHere.id = rider.id; riderHere.riderType = rider.riderType; RiderInfoOper.Instance.Update(riderHere); if (rider.riderType == 2) { var ua = UserAddressOper.Instance.GetByRiderId(riderId); if (ua == null) { ua = new UserAddress(); ua.riderId = riderId; var rp = CacheHelper.GetRiderPosition(riderId); ua.lat = rp.lat; ua.lng = rp.lng; ua.mapAddress = rider.mapAddress; ua.phone = rider.phone; UserAddressOper.Instance.Add(ua); } } return(ControllerHelper.Instance.JsonResult(200, "riderType", rider.riderType.ToString(), "更换成功")); } catch (Exception e) { return(ControllerHelper.Instance.JsonResult(500, "更换失败")); } }
protected void btn_modify_Click(object sender, EventArgs e) { if (Session["cudoUser"] != null) { string addpre = ddl_counties.SelectedValue + "," + ddl_streets.SelectedValue + "," + ddl_district.SelectedValue; addpre += "|" + ddl_counties.SelectedItem.Text + ddl_streets.SelectedItem.Text + ddl_district.SelectedItem.Text; addpre += "|" + ddladdtype.Value; UserAddress item = bll.GetAddressByID(Convert.ToInt32(hiddenid.Value)); bool flag = false; foreach (RepeaterItem temp in rpt_list.Items) { HiddenField hf = temp.FindControl("hfaddtype") as HiddenField; if (!item.Address.Split('|')[2].Equals(ddladdtype.Value) && hf.Value == ddladdtype.Value) { flag = true; break; } } //bll.UpdateAddress(item); if (flag) { Utils.alert("已存在相同场所地址,请更换!", "useraddress.aspx"); } else { item.UserName = txtusername.Value; item.Mobile = txtmobile.Value; item.Address = addpre; item.IsDefault = chkdefult.Checked == true ? 1 : 0; bll.UpdateAddress(item); } } PageInit(); }
public ActionResult SberbankInfo(decimal orderID) { if (CommonConst.IsMobile) { var order = OrderService.GetByPKAndUserID(orderID, AuthService.CurrentUser.UserID); if (order != null) { CartService.SetPaymentType(PaymentTypes.SberBank, orderID); } return(BaseView(new PagePart(MHtmls.LongList( MHtmls.Title("Сбербанк"), "Информация о заказ отправлена вам на почту").ToString()))); } var user = UserService.GetByPK(User.UserID); var userAddress = user .UserAddresses.FirstOrDefault(); if (userAddress == null) { userAddress = new UserAddress(); } userAddress.ForSberbank = true; var model = new SberbankInfoVM { OrderID = orderID, UserAddress = userAddress, Manager = GetSiteManager(orderID) }; model.Contacts = new ContactsVM(); Services.Profile.ProfileService.InitPhones(user, model.Contacts); return(View(model)); }
public async Task <ActionResult> AddNewAddress(UserAddressPostModel userAddressPostModel) { if (!_userAddressService.IsValidAddress(userAddressPostModel)) { return(Ok(new { error_message = "Cu phap khong hop le" })); } User user = await _userServices.GetUserById(userAddressPostModel.UserId); if (user is null) { return(Ok(new { error_message = "Khong ton tai User" })); } DistrictAddress districtAddress = await _cityServices.GetCityAndDistrictAsync(userAddressPostModel); if (districtAddress is null) { return(Ok(new { error_message = "Khong ton tai dia chi nay" })); } await _userAddressService.SetAllUserAddressToFalseAsync(userAddressPostModel.UserId); UserAddress userAddress = _mapper.Map <UserAddress>(userAddressPostModel); bool isSaveUserAddress = await _userAddressService.AddUserAddress(userAddress); if (isSaveUserAddress) { return(Ok(new { data = userAddress })); } else { return(Ok(new { error_message = "Co loi khi them dia chi moi" })); } }
// GET: UserInfo/Delete/5 public ActionResult Delete(string userId) { string userName = User.Identity.GetUserName(); if (String.IsNullOrEmpty(userId)) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AspNetUser us = db.AspNetUsers.Find(userId); if (us == null) { return(HttpNotFound()); } if (userName == us.UserName) { TempData["error"] = "You cannot delete yourself"; return(RedirectToAction("Index")); } UserAddress userAddress = db.UserAddresses.Where(z => z.UserName == us.UserName).FirstOrDefault(); if (userAddress == null) { return(View(new UserAddress(us.UserName, string.Empty, string.Empty, string.Empty, string.Empty, userId))); } else { userAddress.userId = userId; } return(View(userAddress)); }
public ActionResult AddAddress(AddressVm vm) { if (ModelState.IsValid) { var model = new Address(); model.AddressFirst = vm.AddressFirst; model.AddressSecond = vm.AddressSecond; model.PostalCode = vm.PostalCode; model.City = vm.City; model.Country = vm.Country; addressService.Add(model); var uAddress = new UserAddress(); uAddress.UserId = vm.UserId; uAddress.AddressId = model.AddressId; userAddressService.Add(uAddress); return(RedirectToAction("Loggedin", "Address")); } else { ModelState.AddModelError("", "You have to fill all required fields."); return(View()); } }
public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,ImagePath,ImageData,Created,Email,AddressOne,AddressTwo,City,State,ZipCode,PhoneNumber")] UserAddress userAddress) { if (id != userAddress.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(userAddress); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserAddressExists(userAddress.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(userAddress)); }
///<summary> /// 用户地址更新 ///</summary> ///<param name="o">UserAddress</param> ///<returns></returns> public bool UserAddressUpdate(UserAddress o) { return(Try(nameof(UserAddressUpdate), () => { var cmd = SqlBuilder.Update("UserAddress") //.Column("GroupId", o.GroupId) .Column("Consignee", o.Consignee) .Column("CompanyName", o.CompanyName ?? string.Empty) //.Column("CountryId", o.CountryId) .Column("RegionId", o.RegionId) .Column("Province", o.Province) .Column("City", o.City) .Column("District", o.District) .Column("Street", o.Street) .Column("PostalCode", o.PostalCode) .Column("Phone", o.Phone ?? string.Empty) .Column("Mobile", o.Mobile ?? string.Empty) .Column("IsDefault", o.IsDefault) .Column("ModifiedBy", o.ModifiedBy) .Column("ModifiedOn", o.ModifiedOn) .Where("Id=@id and UserId=@userId", new { o.Id, o.UserId }) .ToCommand(); return PassportConn.Execute(cmd) > 0; })); }
protected async override Task <HandleResult> HandleCoreAsync(AddAddressRequest reqObj) { var addr = new UserAddress(); addr.Address = reqObj.Address; addr.Province = reqObj.Province; addr.City = reqObj.City; addr.Contact = reqObj.Contact; addr.District = reqObj.District; addr.Mobile = reqObj.Mobile; addr.IsDefault = false; addr.UID = reqObj.UserId; addr.Zip = reqObj.Zip; int rowAfftected = await _userRepo.AddAddressAsync(addr); if (rowAfftected > 0) { return(new HandleResult <long> { Data = addr.ID, Msg = string.Empty, State = HandleStates.Success }); } return(new HandleResult { State = HandleStates.NoDataFound, Msg = "出了点问题,请稍后重试" }); }
public async Task <IActionResult> Create(UserAddressFormViewModel model) { if (ModelState.IsValid) { var currentUser = await _workContext.GetCurrentUser(); var address = new Address { AddressLine1 = model.AddressLine1, AddressLine2 = model.AddressLine2, ContactName = model.ContactName, CountryId = model.CountryId, StateOrProvinceId = model.StateOrProvinceId, DistrictId = model.DistrictId, City = model.City, ZipCode = model.ZipCode, Phone = model.Phone }; var userAddress = new UserAddress { Address = address, AddressType = AddressType.Shipping, UserId = currentUser.Id }; _userAddressRepository.Add(userAddress); _userAddressRepository.SaveChanges(); return(RedirectToAction("List")); } PopulateAddressFormData(model); return(View(model)); }
///<summary> /// 用户地址创建 ///</summary> ///<param name="o">UserAddress</param> ///<returns></returns> public int UserAddressCreate(UserAddress o) { return(Try(nameof(UserAddressCreate), () => { var cmd = SqlBuilder.Insert("UserAddress") .Column("UserId", o.UserId) .Column("GroupId", o.GroupId) .Column("Consignee", o.Consignee) .Column("CompanyName", o.CompanyName) .Column("CountryId", o.CountryId) .Column("RegionId", o.RegionId) .Column("Province", o.Province) .Column("City", o.City) .Column("District", o.District) .Column("Street", o.Street) .Column("PostalCode", o.PostalCode) .Column("Phone", o.Phone) .Column("Mobile", o.Mobile) .Column("IsDefault", o.IsDefault) .Column("CreatedOn", o.CreatedOn) .Column("ModifiedBy", o.ModifiedBy) .Column("ModifiedOn", o.ModifiedOn) .ToCommand(true); return PassportConn.ExecuteScalar <int>(cmd); })); }
private UserAddress MakeShippingAddress() { var country = new Country { Name = "France" }; var stateOrProvince = new StateOrProvince { Name = "IDF", Country = country, Type = "State" }; var district = new District { Location = "Center", StateOrProvince = stateOrProvince, Name = "Paris" }; var address = new Address { CountryId = 1, AddressLine1 = "115 Rue Marcel", Country = country, StateOrProvince = stateOrProvince, District = district }; var userAddress = new UserAddress { UserId = 1, Address = address, AddressType = AddressType.Shipping }; return(userAddress); }
public async Task<IHttpActionResult> PutUserAddress(int id, UserAddress userAddress) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != userAddress.Id) { return BadRequest(); } db.Entry(userAddress).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserAddressExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task <IActionResult> Edit(int id, [Bind("UserID,City,Country")] UserAddress userAddress) { if (id != userAddress.UserID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(userAddress); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserAddressExists(userAddress.UserID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["UserID"] = new SelectList(_context.Users, "UserID", "FirstName", userAddress.UserID); return(View(userAddress)); }
public static void AddNewClient(string firstName, string lastName, string username, string password, string email, string streetAddress, int zipCode, int stateID) { HumaneSocietyDataContext db = new HumaneSocietyDataContext(); Client client = new Client(); client.firstName = firstName; client.lastName = lastName; client.userName = username; client.pass = password; client.email = email; UserAddress address = new UserAddress(); address.addessLine1 = streetAddress; address.zipcode = zipCode; var userState = ( from state in db.USStates where state.ID == stateID select state ).ToList(); address.USState = userState[0]; db.UserAddresses.InsertOnSubmit(address); db.SubmitChanges(); var userAddress = ( from addresses in db.UserAddresses where streetAddress == address.addessLine1 select address ).ToList(); client.userAddress = userAddress[0].ID; db.Clients.InsertOnSubmit(client); db.SubmitChanges(); }
public ComplexResponse <int> Edit(UserAddress model) { var msg = ErrorMessage.失败; int data = 0; if (model.Id <= 0) { model.IsDefault = 0; model.CreateTime = model.UpdateTime = DateTime.Now; model.IsDeleted = 0; model.Status = 1; model.IsDefault = 0; data = (int)_addressService.Insert(model); if (data > 0) { msg = ErrorMessage.成功; } } else { var flag = _addressService.Update(model, p => p.Name.Equals("Receiver") || p.Name.Equals("Mobile") || p.Name.Equals("Province") || p.Name.Equals("City") || p.Name.Equals("District") || p.Name.Equals("Address") || p.Name.Equals("PostCode")); if (flag) { msg = ErrorMessage.成功; } } return(new ComplexResponse <int>((int)msg, msg.ToString(), data)); }
public HttpResponseMessage AddAddress(AddAddrReq req) { UserAddress ua = new UserAddress(); ua.userId = Convert.ToInt32(req.userId); var tokenStr = req.Token; Token token = CacheHelper.GetUserToken(tokenStr); if (token == null) { return(ControllerHelper.Instance.JsonResult(400, "token失效")); } if (token.Payload.UserID != ua.userId) { return(ControllerHelper.Instance.JsonResult(400, "token错误")); } ua.name = req.name; ua.phone = req.phone; ua.mapAddress = req.address; ua.detail = req.detail; ua.lat = req.lat; ua.lng = req.lng; try { var id = UserAddressOper.Instance.Add(ua); return(ControllerHelper.Instance.JsonResult(200, "addressId", id.ToString(), "添加地址成功")); } catch (Exception e) { return(ControllerHelper.Instance.JsonResult(500, "网络不稳定")); } }
public void EditUserAddress_ForNotExistingAddress_ReturnsNewAddress() { var fakeHttpContext = new Mock <HttpContextBase>(); var fakeIdentity = new GenericIdentity("User"); fakeIdentity.AddClaim(new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier", "UserId")); var principal = new GenericPrincipal(fakeIdentity, null); fakeHttpContext.Setup(t => t.User).Returns(principal); var controllerContext = new Mock <ControllerContext>(); controllerContext.Setup(t => t.HttpContext).Returns(fakeHttpContext.Object); Mock <IUserRepository> mock = new Mock <IUserRepository>(); mock.Setup(m => m.AddOrSaveUserAddress(It.IsAny <UserAddress>())).Returns(true); //Set your controller ControllerContext with fake context UserAddressController controller = new UserAddressController(mock.Object, null, new CountriesProvider()) { ControllerContext = controllerContext.Object }; UserAddress result = (UserAddress)controller.Edit().ViewData.Model; Assert.IsNotNull(result); Assert.AreEqual(result.Id, 0); Assert.AreEqual(result.UserId, "UserId"); }
public IActionResult Create(UserViewModel uvm) { string uniqueFileName = UploadedFile(uvm); Users user = new Users() { user_email = uvm.user_email, user_age = uvm.user_age, user_name = uvm.user_name, user_phone = uvm.user_phone, user_pwd = uvm.user_pwd, user_ImagePath = uniqueFileName }; int id = _IBOUsers.CreateUser(user); UserAddress userAd = new UserAddress() { city_name = uvm.cityName, userID = id }; int addressId = _IBOUsers.SaveAddress(userAd); //controller create action if (id == 0 || addressId == 0) { TempData["IsFail"] = "UnSccessfull"; return(RedirectToAction("Register", "Admin")); } else { TempData["IsSuccess"] = "Inserted Successfully"; return(RedirectToAction("Create")); } }
public void EditUserAddress_ForExistingAddress_ReturnsAddres() { var fakeHttpContext = new Mock <HttpContextBase>(); var fakeIdentity = new GenericIdentity("User"); var principal = new GenericPrincipal(fakeIdentity, null); fakeHttpContext.Setup(t => t.User).Returns(principal); var controllerContext = new Mock <ControllerContext>(); controllerContext.Setup(t => t.HttpContext).Returns(fakeHttpContext.Object); UserAddress userAddress = new UserAddress { Id = 1, UserId = new Guid().ToString() }; Mock <IUserRepository> mock = new Mock <IUserRepository>(); mock.Setup(m => m.GetUserAddress(It.IsAny <string>())).Returns(userAddress); //Set your controller ControllerContext with fake context UserAddressController controller = new UserAddressController(mock.Object, null, new CountriesProvider()) { ControllerContext = controllerContext.Object }; UserAddress result = (UserAddress)controller.Edit().ViewData.Model; Assert.IsNotNull(result); Assert.AreEqual(result.Id, userAddress.Id); Assert.AreEqual(result.UserId, userAddress.UserId); }
public UserAddress CreateUserAddress(UserAddress userAddress) { db.UserAddresses.Add(userAddress); db.SaveChanges(); return(userAddress); }
public void EditUserAddress_ValidData_ChangesSaved() { UserAddress userAddress = new UserAddress { Id = 1, UserId = new Guid().ToString() }; var fakeHttpContext = new Mock <HttpContextBase>(); var fakeIdentity = new GenericIdentity("User"); fakeIdentity.AddClaim(new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier", "UserId")); var principal = new GenericPrincipal(fakeIdentity, null); fakeHttpContext.Setup(t => t.User).Returns(principal); var controllerContext = new Mock <ControllerContext>(); controllerContext.Setup(t => t.HttpContext).Returns(fakeHttpContext.Object); Mock <IUserRepository> mock = new Mock <IUserRepository>(); mock.Setup(m => m.AddOrSaveUserAddress(It.IsAny <UserAddress>())).Returns(true); //Set your controller ControllerContext with fake context UserAddressController controller = new UserAddressController(mock.Object, null, new CountriesProvider()) { ControllerContext = controllerContext.Object }; var result = controller.Edit(userAddress); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult)); }
// public DateTime? GetBirthday { // get { return DateTime.ParseExact(Birthday, "dd.MM.yyyy", CultureInfo.InvariantCulture); } // } public RegisterVM() { User = new User(); User.Company = new Company(); Phone = new PhoneVM(); UserAddress = new UserAddress(); }
/// <summary> /// Adds the new user address. /// </summary> /// <param name="userAddress">The model.</param> /// <returns></returns> public long AddNewUserAddress(UserAddress userAddress) { try { var userAddressModel = context.UserAddress.Where(x => x.Address1 == userAddress.Address1 && x.Address2 == userAddress.Address2 && x.City == userAddress.City && x.CountryFK == userAddress.CountryFK && x.StateFK == userAddress.StateFK && x.UserFK == x.UserFK && x.Zipcode == userAddress.Zipcode && x.IsDelete == false).FirstOrDefault(); if (userAddressModel == null) { var checkPrimary = context.UserAddress.Where(x => x.UserFK == userAddress.UserFK && x.IsPrimary == true && x.IsDelete == false).Count(); if (checkPrimary > 0) { return(ReturnCode.IsPrimaryExist.GetHashCode()); } context.UserAddress.Add(userAddress); context.SaveChanges(); return(userAddress.UserAddressId); } else { return(ReturnCode.AlreadyExist.GetHashCode()); } } catch (Exception ex) { LogHelper.ExceptionLog(ex.Message + " ::::: " + ex.StackTrace); throw ex; } }
private void btnInsert_Click(object sender, RoutedEventArgs e) { if (txtAddress.Text != "" && txtCity.Text != "" && txtZip.Text != "") { address = new UserAddress() { Id = Guid.Empty, UserId = userId, Address = txtAddress.Text, City = txtCity.Text, StateId = cboState.SelectedIndex, ZipCode = txtZip.Text, }; bool result = UserAddressManager.Insert(address); if (result) { MessageBox.Show("Address added."); this.Close(); } else { MessageBox.Show("An error occurred when inserting."); } } else { MessageBox.Show("Error. Please enter data into the fields."); } }
public async Task <Result> Post([FromBody] UserAddressCreateParam param) { var user = await _workContext.GetCurrentUserAsync(); var countryId = (int)CountryWithId.China; var provinces = await _countryService.GetProvinceByCache(countryId); if (provinces == null || provinces.Count <= 0) { throw new Exception("省市区数据异常,请联系管理员"); } if (!provinces.Any(c => c.Id == param.StateOrProvinceId && c.Level == StateOrProvinceLevel.Default)) { throw new Exception("所选择省信息不存在"); } if (!provinces.Any(c => c.Id == param.CityId && c.Level == StateOrProvinceLevel.City && c.ParentId == param.StateOrProvinceId)) { throw new Exception("所选择市信息不存在"); } if (param.DistrictId.HasValue) { if (!provinces.Any(c => c.Id == param.DistrictId && c.Level == StateOrProvinceLevel.District && c.ParentId == param.CityId)) { throw new Exception("所选择区/县信息不存在"); } } var address = new Address() { AddressLine1 = param.AddressLine1, ContactName = param.ContactName, Phone = param.Phone, CountryId = countryId, StateOrProvinceId = param.DistrictId ?? param.CityId, // 存储最小结构数据 }; var userAddress = new UserAddress() { Address = address, UserId = user.Id, AddressType = AddressType.Shipping }; _userAddressRepository.Add(userAddress); var tran = _userAddressRepository.BeginTransaction(); await _userAddressRepository.SaveChangesAsync(); if (param.IsDefault) { var dbUser = await _userRepository.FirstOrDefaultAsync(user.Id); dbUser.DefaultShippingAddress = userAddress; await _userRepository.SaveChangesAsync(); } tran.Commit(); return(Result.Ok()); }
protected void rpt_list_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "del") { bll.DeleteAddress(Convert.ToInt32(e.CommandArgument)); } if (e.CommandName == "edit") { btn_Add.Visible = false; btn_modify.Visible = true; UserAddress item = bll.GetAddressByID(Convert.ToInt32(e.CommandArgument)); ddladdtype.Value = item.Address.Split('|')[2]; txtusername.Value = item.UserName; txtmobile.Value = item.Mobile; chkdefult.Checked = item.IsDefault == 1 ? true : false; hiddenid.Value = e.CommandArgument.ToString(); string[] itemlist = item.Address.Split('|')[0].Split(','); AreaInit(itemlist[0]); StreetInit(itemlist[0], itemlist[1]); DistrictInit(itemlist[1], itemlist[2]); } if (e.CommandName == "default") { UserAddress item = bll.GetAddressByID(Convert.ToInt32(e.CommandArgument)); item.IsDefault = 1; bll.UpdateAddress(item); } PageInit(); }
public static async Task <string> EditUserAddress(UserAddress useraddress) { string hashedToken = getHashedToken(); var response = await UserAPI_Logic.EditUserAddress(hashedToken, useraddress); return(response); }
public bool AddOrSaveUserAddress(UserAddress userAddress) { try { if (userAddress.Id == default(int)) { userAddress.User = GetUserById(userAddress.UserId); _context.UserAddresses.Add(userAddress); } else { var existingUserAddress = _context.UserAddresses .SingleOrDefault(u => u.Id == userAddress.Id); // Update _context.Entry(existingUserAddress).CurrentValues.SetValues(userAddress); } _context.SaveChanges(); return(true); } catch (Exception ex) { Debug.Write(ex.Message); return(false); } }
public static UserAddress GetDefaultAddress(int userid) { UserAddress item = null; string spName = "cudo_getdefaultaddressbyuserid"; SqlParameter[] paramvalues = new SqlParameter[] { new SqlParameter("@userid", userid) }; SqlDataReader dataReader = SqlHelper.ExecuteReader(SqlHelper.ConnectionString, CommandType.StoredProcedure, spName, paramvalues); try { if (dataReader.Read()) { item = new UserAddress(); item.UserId = userid; item.UserName = dataReader["username"].ToString(); item.Mobile = dataReader["mobile"].ToString(); item.Address = dataReader["address"].ToString(); } } catch { dataReader.Close(); dataReader.Dispose(); } finally { dataReader.Close(); dataReader.Dispose(); } return(item); }
public IHttpActionResult PostUserAddress(UserAddress userAddress) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.CreateUserAddress(userAddress); return CreatedAtRoute("DefaultApi", new { id = userAddress.UserAddressID }, userAddress); }
public async Task<IHttpActionResult> PostUserAddress(UserAddress userAddress) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.UserAddresses.Add(userAddress); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = userAddress.Id }, userAddress); }
public IHttpActionResult Post(UserAddress userAddress) { _command.Send(new UserAddressDetails() { Addresses = userAddress.Addresses.Select(x => new CashLady.Domain.Entities.Address() { City = x.City, County = x.County, DateMovedIn = x.DateMovedIn, DateMovedOut = x.DateMovedOut, FirstLine = x.FirstLine, PostCode = x.PostCode }).ToList(), UserId = userAddress.UserId }); return Ok(); }
public ActionResult UserAddress(UserAddressModel model) { LoadCountries(); mu = Membership.GetUser(); ua = new UserAccount(Convert.ToInt32(mu.ProviderUserKey)); uad = new UserAccountDetail(); uad.GetUserAccountDeailForUser(ua.UserAccountID); BootBaronLib.AppSpec.DasKlub.BOL.UserAddress uadress = new UserAddress(); uadress.GetUserAddress(ua.UserAccountID); TryUpdateModel(model); if (ModelState.IsValid) { uadress.AddressLine1 = model.AddressLine1; uadress.AddressLine2 = model.AddressLine2; uadress.AddressLine3 = model.AddressLine3; uadress.City = model.City; uadress.CountryISO = model.Country; uadress.FirstName = model.FirstName; uadress.LastName = model.LastName; uadress.PostalCode = model.PostalCode; uadress.Region = model.RegionState; uadress.UserAccountID = ua.UserAccountID; if (uadress.UserAddressID == 0) uadress.AddressStatus = 'U'; ViewBag.ProfileUpdated = uadress.Set(); } //if (BootBaronLib.AppSpec.DasKlub.BOL.UserAddress.IsBlank(ua.UserAccountID)) //{ // newUAdd.UserAccountID = ua.UserAccountID; // newUAdd.CreatedByUserID = ua.UserAccountID; // if (Request.Form["no_button"] != null && // Request.Form["no_button"] == "no") // { // newUAdd.AddressStatus = 'N'; // } // else // { // newUAdd.AddressStatus = 'U'; // } // if (!string.IsNullOrEmpty(newUAdd.PostalCode) && (string.IsNullOrEmpty(newUAdd.City) || string.IsNullOrEmpty(newUAdd.Region))) // { // // for those those who think the system can figure them out // SiteEnums.CountryCodeISO coiso = GeoData.GetCountryISOForCountryCode(newUAdd.CountryISO); // SiteStructs.CityRegion cr = GeoData.GetCityRegionForPostalCodeCountry(newUAdd.PostalCode, coiso); // newUAdd.Region = cr.Region; // newUAdd.City = cr.CityName; // } // newUAdd.Create(); //} ////Response.Redirect("/" + ua.UserName); //Response.Redirect("~/thanks.htm"); //uad = new UserAccountDetail(); //uad.GetUserAccountDeailForUser(ua.UserAccountID); return View(model); }
public async Task<IActionResult> DeliveryInformation(DeliveryInformationViewModel model) { if (!ModelState.IsValid && model.ShippingAddressId == 0) { return View(model); } var currentUser = await _workContext.GetCurrentUser(); if (model.ShippingAddressId == 0) { var address = new Address { AddressLine1 = model.NewAddressForm.AddressLine1, ContactName = model.NewAddressForm.ContactName, CountryId = 1, StateOrProvinceId = model.NewAddressForm.StateOrProvinceId, DistrictId = model.NewAddressForm.DistrictId, Phone = model.NewAddressForm.Phone }; var userAddress = new UserAddress { Address = address, AddressType = AddressType.Shipping, UserId = currentUser.Id }; _userAddressRepository.Add(userAddress); currentUser.CurrentShippingAddress = userAddress; } else { currentUser.CurrentShippingAddress = _userAddressRepository.Query().FirstOrDefault(x => x.Id == model.ShippingAddressId); } _orderService.CreateOrder(currentUser); _userAddressRepository.SaveChange(); return RedirectToAction("OrderConfirmation"); }
public ActionResult GiveAway(UserAddressModel model) { LoadCountries(); var uadress = new UserAddress(); TryUpdateModel(model); if (ModelState.IsValid) { uadress.AddressLine1 = model.AddressLine1; uadress.AddressLine2 = model.AddressLine2; uadress.AddressLine3 = model.AddressLine3; uadress.City = model.City; uadress.CountryISO = model.Country; uadress.FirstName = model.FirstName; uadress.LastName = model.LastName; uadress.PostalCode = model.PostalCode; uadress.Region = model.RegionState; if (uadress.UserAddressID == 0) uadress.AddressStatus = 'U'; uadress.Set(); ViewBag.IsSuccess = true; return View(model); } return View(model); }
public ActionResult SaveAddress(UserAddress model, string returnUrl) { var u = YunClient.Instance.Execute(new SaveAddressRequest { Area = model.Area, City = model.City, IsDefault = model.IsDefault ? 1 : 0, Mobile = model.Mobile, Name = model.Name, Province = model.Province, Street = model.Street, Zipcode = model.Zipcode, AddressType = 0, Id = Convert.ToInt32(model.Id) }, Member.Token); if (!returnUrl.IsEmpty()) { return Redirect(returnUrl); } return Json(u.IsError); }
public ActionResult UserAddress() { LoadCountries(); mu = Membership.GetUser(); ua = new UserAccount(Convert.ToInt32(mu.ProviderUserKey)); uad = new UserAccountDetail(); uad.GetUserAccountDeailForUser(ua.UserAccountID); UserAddressModel model = new UserAddressModel(); BootBaronLib.AppSpec.DasKlub.BOL.UserAddress uadress = new UserAddress(); uadress.GetUserAddress(ua.UserAccountID); if (BootBaronLib.Configs.GeneralConfigs.IsGiveAway && uadress.UserAddressID > 0) return View("NotAllowed"); if (uadress.UserAddressID == 0) { model.PostalCode = uad.PostalCode; model.Country = uad.Country; } else { model.AddressLine1 = uadress.AddressLine1; model.AddressLine2 = uadress.AddressLine2; model.AddressLine3 = uadress.AddressLine3; model.City = uadress.City; model.Country = uadress.CountryISO; model.FirstName = uadress.FirstName; model.LastName = uadress.LastName; model.PostalCode = uadress.PostalCode; model.RegionState = uadress.Region; } return View(model); }
public ActionResult GiveAway() { LoadCountries(); var model = new UserAddressModel(); var uadress = new UserAddress(); model.AddressLine1 = uadress.AddressLine1; model.AddressLine2 = uadress.AddressLine2; model.AddressLine3 = uadress.AddressLine3; model.City = uadress.City; model.Country = uadress.CountryISO; model.FirstName = uadress.FirstName; model.LastName = uadress.LastName; model.PostalCode = uadress.PostalCode; model.RegionState = uadress.Region; return View(model); }
public ActionResult UserAddress() { LoadCountries(); if (_mu != null) _ua = new UserAccount(Convert.ToInt32(_mu.ProviderUserKey)); _uad = new UserAccountDetail(); _uad.GetUserAccountDeailForUser(_ua.UserAccountID); var model = new UserAddressModel(); var uadress = new UserAddress(); uadress.GetUserAddress(_ua.UserAccountID); if (GeneralConfigs.IsGiveAway && uadress.UserAddressID > 0) return View("NotAllowed"); if (uadress.UserAddressID == 0) { model.PostalCode = _uad.PostalCode; model.Country = _uad.Country; } else { model.AddressLine1 = uadress.AddressLine1; model.AddressLine2 = uadress.AddressLine2; model.AddressLine3 = uadress.AddressLine3; model.City = uadress.City; model.Country = uadress.CountryISO; model.FirstName = uadress.FirstName; model.LastName = uadress.LastName; model.PostalCode = uadress.PostalCode; model.RegionState = uadress.Region; } return View(model); }
public ActionResult UserAddress(UserAddressModel model) { LoadCountries(); if (_mu != null) _ua = new UserAccount(Convert.ToInt32(_mu.ProviderUserKey)); _uad = new UserAccountDetail(); _uad.GetUserAccountDeailForUser(_ua.UserAccountID); var uadress = new UserAddress(); uadress.GetUserAddress(_ua.UserAccountID); TryUpdateModel(model); if (ModelState.IsValid) { uadress.AddressLine1 = model.AddressLine1; uadress.AddressLine2 = model.AddressLine2; uadress.AddressLine3 = model.AddressLine3; uadress.City = model.City; uadress.CountryISO = model.Country; uadress.FirstName = model.FirstName; uadress.LastName = model.LastName; uadress.PostalCode = model.PostalCode; uadress.Region = model.RegionState; uadress.UserAccountID = _ua.UserAccountID; // uadress.Choice1 = "||" + Request.Form["sex"] + "|" + Request.Form["size"]; if (uadress.UserAddressID == 0) uadress.AddressStatus = 'U'; ViewBag.ProfileUpdated = uadress.Set(); Response.Redirect("/account/home"); } return View(model); }
private void SendMassMail(string message) { _mail = new MailService(); int totalSent = 0; var uas = new UserAccounts(); uas.GetAll(); foreach (UserAccount ua1 in uas.OrderBy(x => x.CreateDate)) { var uad = new UserAccountDetail(); uad.GetUserAccountDeailForUser(ua1.UserAccountID); if (!uad.EmailMessages) continue; // safety if (ua1.UserName != "bootlegbaron") continue; var userAddress = new UserAddress(); userAddress.GetUserAddress(ua1.UserAccountID); System.Threading.Thread.Sleep(200); if (_mail.SendMail("*****@*****.**", ua1.EMail, "Das Klub Kalendar 2017 - Competition!", message)) { totalSent++; } else { uad.EmailMessages = false; uad.Update(); } } HttpContext.Current.Response.Write(totalSent); }
// Address formatting specific to the US, depending upon the countries supported you may // have different address formatting static string FormatUsAddress (UserAddress address) { var builder = new StringBuilder (); builder.Append ("\n"); if (!string.IsNullOrEmpty (address.Address1)) builder.Append (address.Address1 + ", "); if (!string.IsNullOrEmpty (address.Locality)) builder.Append (address.Locality + ", "); if (!string.IsNullOrEmpty (address.AdministrativeArea)) builder.Append (address.AdministrativeArea + ", "); if (!string.IsNullOrEmpty (address.CountryCode)) builder.Append (address.CountryCode); return builder.ToString (); }