public ActionResult CreateUserAddress(UserAdress entity) { entity.CreateDate = DateTime.Now; entity.CreateUserID = LoginUserID; entity.IsActive = true; entity.UserID = LoginUserID; var db = new AndDB(); db.Adresses.Add(entity); db.SaveChanges(); return(RedirectToAction("AddressList")); }
public OrderRES OrderDTtoRES() { OrderRES orderRES = new OrderRES() { Id = Id, OrderDate = OrderDate, OrderDetails = OrderDetails.Select(x => x.OrderDetailDTtoRES()).ToList(), OrderStatus = OrderStatus, UserAdress = UserAdress.UserAdressDTtoRES() }; return(orderRES); }
public IActionResult OnPost(string Adress, string CareOf, int ZipCode, string City) { using (ApplicationDbContext ctx = new ApplicationDbContext()) { AdressModel adressModel = new AdressModel(); var signedInUserID = this.User.FindFirstValue(ClaimTypes.NameIdentifier).ToString(); var checkEmptyAdress = from e in ctx.UserAdress select e; if (checkEmptyAdress.Count() == 0) { isAdressEmpty = true; } if (isAdressEmpty == true) { var query = from user in ctx.UserAdress where user.UserID == Guid.Parse(signedInUserID) select user; UserAdress ua = new UserAdress(); ua.Adress = Adress; ua.CareOf = CareOf; ua.ZipCode = ZipCode.ToString(); ua.City = City; ua.UserID = Guid.Parse(signedInUserID); ctx.UserAdress.Add(ua); ctx.SaveChanges(); } else { var query = from user in ctx.UserAdress where user.UserID == Guid.Parse(signedInUserID) select user; foreach (var adress in query) { adress.Adress = Adress; adress.CareOf = CareOf; adress.ZipCode = ZipCode.ToString(); adress.City = City; adress.UserID = Guid.Parse(signedInUserID); } ctx.SaveChanges(); } } return(Page()); }
/// <summary> /// 删除我的收货地址 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult AdressDel(int id) { UserAdress ua = new UserAdress() { Id = id }; if (UserAdressBll.Delete(ua)) { return(Content("ok")); } else { return(Content("no")); } }
// GET: Users/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } User user = db.Users.Find(id); Adress adress = db.Adresses.FirstOrDefault(adr => adr.UserId == id); UserAdress userAddres = new UserAdress(user, adress); if (user == null) { return(HttpNotFound()); } return(View(userAddres)); }
public async Task UpdateAdress(int userId, UserAdress userAdress) { var updateAdress = await _context.UserAdresses.FirstOrDefaultAsync(u => u.UserId == userId); if (userAdress == null) { throw new HttpException(404, "İstifadəçi ünvanı tapılmadı"); } updateAdress.Country = userAdress.Country; updateAdress.City = userAdress.City; updateAdress.Adress1 = userAdress.Adress1; updateAdress.Adress2 = userAdress.Adress2; updateAdress.Postcode = userAdress.Postcode; updateAdress.ModifiedDate = DateTime.Now; updateAdress.ModifiedBy = userAdress.ModifiedBy; await _context.SaveChangesAsync(); }
protected override async void Run(Session session, C2G_QueryUserAdress message, Action <G2C_QueryUserAdress> reply) { G2C_QueryUserAdress response = new G2C_QueryUserAdress(); UserAdress userAdress = null; try { DBProxyComponent dBProxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); var acounts = await dBProxyComponent.Query <UserAdress>("{ '_AccountID': " + message.AccountID + "}"); if (acounts.Count <= 0) { UserAdress Info = ComponentFactory.Create <UserAdress>(); Info._AccountID = message.AccountID; Info._InfoID = message.InfoID; Info._AdressList = new List <string>(); response.AdressList = RepeatedFieldAndListChangeTool.ListToRepeatedField(Info._AdressList); await dBProxyComponent.Save(Info); await dBProxyComponent.SaveLog(Info); } else { userAdress = acounts[0] as UserAdress; response.AdressList = RepeatedFieldAndListChangeTool.ListToRepeatedField(userAdress._AdressList); await dBProxyComponent.Save(userAdress); await dBProxyComponent.SaveLog(userAdress); } reply(response); } catch (Exception e) { response.Message = "数据库异常"; ReplyError(response, e, reply); } }
public void AddOrder(Guid id, int adressId) { VotedressUser votedressUser = unitOfWork.Repository <VotedressUser>().Find(x => x.id == id); if (votedressUser != null) { UserAdress userAdress = unitOfWork.Repository <UserAdress>().Find(x => x.User.id == id && x.id == adressId); Order order = new Order() { OrderDate = DateTime.Now, User = votedressUser, UserAdress = userAdress, Status = "Onay Bekliyor" }; unitOfWork.Repository <Order>().Insert(order); unitOfWork.SaveChanges(); CartManager cartManager = new CartManager(); Cart carts = unitOfWork.Repository <Cart>().Find(x => x.User.id == id); OrderDetail orderDetail; foreach (var cartDetail in carts.CartDetail) { orderDetail = new OrderDetail() { Order = order, Product = cartDetail.Product, ProductColorId = cartDetail.ProductColorId, ProductCount = cartDetail.ProductCount, Size = cartDetail.Size, }; unitOfWork.Repository <OrderDetail>().Insert(orderDetail); } unitOfWork.SaveChanges(); } }
protected override async void Run(Session session, C2G_AddressManager message, Action <G2C_AddressManager> reply) { G2C_AddressManager response = new G2C_AddressManager(); try { Log.Debug("地址管理"); DBProxyComponent dBProxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); //读取数据表 if (message.DoState == 1) { var acounts = await dBProxyComponent.Query <UserAdress>("{'_AccountID' : " + message.AccountID + "}"); if (acounts.Count == 1) { foreach (UserAdress item in acounts) { response.InfoID = item._InfoID; response.AdressList = RepeatedFieldAndListChangeTool.ListToRepeatedField(item._AdressList); } response.IsSuccess = true; response.Message = MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "拿取数据成功"; } else if (acounts.Count == 0) { response.IsSuccess = false; response.Message = MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "无数据"; } else { response.IsSuccess = false; response.Message = MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "地址数据错误"; } } //操作数据表 else if (message.DoState == 2) { Log.Debug("操作数据表"); var acounts = await dBProxyComponent.Query <UserAdress>("{'_AccountID' : " + message.AccountID + "}"); //修改 if (acounts.Count == 1) { foreach (UserAdress item in acounts) { if (message.AddressType == 1) { item._AdressList.Insert(0, message.DetailsAddress); await dBProxyComponent.Save(item); response.IsSuccess = true; response.Message = MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "修改地址成功"; } if (message.AddressType == 2) { item._AdressList.Remove(message.DetailsAddress); await dBProxyComponent.Save(item); response.IsSuccess = true; response.Message = MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "修改地址成功"; } } } //保存数据表 else if (acounts.Count == 0) { UserAdress adressData = ComponentFactory.Create <UserAdress>(); adressData._AccountID = message.AccountID; adressData._InfoID = adressData.Id; adressData._AdressList = new List <string>(); await dBProxyComponent.Save(adressData); Log.Debug(MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "添加地址成功"); response.IsSuccess = true; response.Message = MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "添加地址成功"; } else { response.IsSuccess = false; response.Message = MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "地址数据错误"; } } reply(response); } catch (Exception e) { response.IsSuccess = false; response.Message = MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "数据库异常"; ReplyError(response, e, reply); } }
public ActionResult ConfirmPayment(FormCollection form) { var items = (List <Item>)Session["cart"]; float subTot = 0; float total = 0; if (items != null) { foreach (Item itemPro in (List <Item>)Session["cart"]) { float price = Convert.ToSingle(itemPro.Pro.Price) * 1; subTot = subTot + price; } total = subTot + 100; } decimal amount = Math.Round((decimal)total, 0); try { Applicant applicant = new Applicant(); Address address = new Address(); //var loanAmount = form["loanAmmount"]; applicant.firstName = form["name"]; applicant.lastName = form["name"]; string tempDate = (form["DOB"]); string createddate = Convert.ToDateTime(tempDate).ToString("yyyy-MM-dd"); applicant.dateOfBirth = createddate; applicant.mobile = form["mobile"]; applicant.email = form["email"]; applicant.identificationNumber = form["ssn"]; if (form["housingType"] != null) { applicant.housingType = form["housingType"]; } else { applicant.housingType = ""; } applicant.salaryFrequency = form["salaryFrequency"]; applicant.employmentStatus = form["employmentStatus"]; address.street1 = Session["address"].ToString(); address.city = Session["City"].ToString(); address.state = Session["state"].ToString(); address.zipCode = Session["Zip"].ToString(); address.country = Session["country"].ToString(); applicant.address = address; var grossIncome = form["grossIncome"]; TempData["matches"] = new OfferService().GetOffers(amount.ToString(), grossIncome, applicant); // IEnumerable<OfferViewModel> ResponceOffer = new OfferService().GetOffers(loanAmount, grossIncome, applicant); if (TempData["matches"] != null) { using (db = new ChargeAfterEntities()) { var user = new User(); var userAddress = new UserAdress(); var req = new Request(); var name = form["name"]; var email = form["email"]; user.FirstName = form["name"]; user.Mobile = form["mobile"]; user.Email = form["email"]; user.DOB = Convert.ToDateTime(form["DOB"]); user.EstimatedCreditRange = form["CreditScore"]; user.EmploymentStatus = form["employmentStatus"]; user.HousingStatus = form["housingType"]; user.GrossAnnualIndividual = form["grossIncome"]; user.NetMonthlyIncome = form["netMonthly"]; user.SalaryFrequency = form["salaryFrequency"]; db.Users.Add(user); db.SaveChanges(); userAddress.UserId = user.Id; tempID = user.Id; Session["id"] = user.Id; userAddress.Country = Session["country"].ToString(); userAddress.Adress = Session["address"].ToString(); userAddress.City = Session["City"].ToString(); userAddress.State = Session["state"].ToString(); userAddress.PostalCode = Session["Zip"].ToString(); db.UserAdresses.Add(userAddress); req.UserID = user.Id; req.RequestDate = DateTime.Now; req.RequestAmount = amount; req.RequestStatus = "Pending"; TempData["id"] = user.Id; db.Requests.Add(req); db.SaveChanges(); ViewData["message"] = "Sucessful"; } using (db = new ChargeAfterEntities()) { var offer = new RequestOffer(); var item = (List <Item>)Session["cart"]; float subTots = 0; float pay = 0; decimal approvedAmount = 0; if (item != null) { foreach (Item itemPro in (List <Item>)Session["cart"]) { float price = Convert.ToSingle(@itemPro.Pro.Price) * 1; subTots = subTots + price; Session["Subtotal"] = subTots; } pay = Convert.ToSingle(100 + subTots); approvedAmount = Math.Round((decimal)pay, 0); } decimal monthly = approvedAmount / 12; decimal monthlyPay = Math.Round((decimal)monthly, 0); IEnumerable <OfferViewModel> offered = (IEnumerable <OfferViewModel>)TempData["matches"]; foreach (var itms in offered) { if (offered.Count() == 0) { offer.Lender = "No Lender Avaialable"; offer.Ammount = 0; offer.Duration = " "; offer.Intrest = " "; ////viewmodel.loanId = "f8c5774a-d532-49eb-8cac-c5cdb5a6b52c"; offer.LoanId = "0"; offer.OffID = 0; } offer.UserID = long.Parse(tempID.ToString()); offer.TotalPayback = itms.term; offer.IncreasePercent = int.Parse(itms.interestRate.ToString()); offer.ApprovedAmmount = decimal.Parse(itms.loanAmount.ToString()); try { offer.MonthlyAmount = decimal.Parse(itms.monthlyPayment.ToString()); } catch (Exception ex) { offer.MonthlyAmount = 0; } offer.annualFee = itms.annualFee; offer.Duration = itms.Duration; offer.eligibility = itms.eligibility; offer.Intrest = itms.Intrest; offer.minApr = itms.apr.ToString(); offer.isPreQualifyOffer = itms.isPreQualifyOffer; //offer.legalDisclosure = itms.legalDisclosure.ToString(); offer.LoanId = itms.loanId; //offer.maxMonthlyPayment = itms.maxMonthlyPayment.ToString(); //offer.minApr = itms.minApr.ToString(); offer.MonthCount = itms.term; //offer.pendingOffers = itms.pendingOffers.ToString(); offer.status = itms.status; offer.term = itms.term; offer.Lender = itms.Lender; db.RequestOffers.Add(offer); db.SaveChanges(); } return(RedirectToAction("Offers")); } } else { return(View()); } } catch (Exception ex) { ViewData["message"] = "Sorry " + ex.Message; return(View()); } }
public void Update(UserAdress userAdress) { context.Entry(userAdress).State = Microsoft.EntityFrameworkCore.EntityState.Modified; context.SaveChanges(); }
public void Remove(UserAdress userAdress) { userAdress.Status = DAL.Entity.Enum.Status.Deleted; Update(userAdress); }
public void Add(UserAdress userAdress) { context.UserAdresses.Add(userAdress); context.SaveChanges(); }
public ActionResult Payment(string Name, string Uemail, string phone, string dateBirth, string SSN, string EmplStatus, string estimatedCredit, string housingStatus, string NetMonthlySalary, string GrossIn, string SalaryFrequency, string Address, string State, string City, string monthRent, string driverLicenseNum, string driversState, string driversDate, string yearsAtResidance, FormCollection form) { try { using (db = new ChargeAfterEntities()) { var user = new User(); var userAddress = new UserAdress(); var req = new Request(); var name = Name; var email = Uemail; user.FirstName = Name; user.Mobile = phone; user.Email = Uemail; if (dateBirth != null) { user.DOB = Convert.ToDateTime(dateBirth); } user.SocialSecurityNumber = SSN; user.EstimatedCreditRange = estimatedCredit; user.EmploymentStatus = EmplStatus; user.HousingStatus = housingStatus; user.GrossAnnualIndividual = GrossIn; user.NetMonthlyIncome = NetMonthlySalary; user.SalaryFrequency = SalaryFrequency; user.YearatResidence = yearsAtResidance; user.monthlyRent = monthRent; user.DriverLicense = driverLicenseNum; user.DriverLicenseState = driversState; if (driversDate.Length > 1) { user.DriverLicensExpirationDate = Convert.ToDateTime(driversDate); } db.Users.Add(user); db.SaveChanges(); userAddress.UserId = user.Id; userAddress.Country = Session["country"].ToString(); userAddress.Adress = Address; userAddress.City = City; userAddress.State = State; userAddress.PostalCode = Session["Zip"].ToString(); db.UserAdresses.Add(userAddress); var items = (List <Item>)Session["cart"]; float subTot = 0; float total = 0; if (items != null) { foreach (Item itemPro in (List <Item>)Session["cart"]) { float price = Convert.ToSingle(@itemPro.Pro.Price) * 1; subTot = subTot + price; } total = subTot + 100; } decimal amount = Math.Round((decimal)total, 0); req.UserID = user.Id; req.RequestDate = DateTime.Now; req.RequestAmount = amount; req.RequestStatus = "Pending"; TempData["id"] = user.Id; Session["idU"] = user.Id; int userId = user.Id; db.Requests.Add(req); db.SaveChanges(); ViewData["message"] = "Sucessful"; return(Json(userId, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { ViewData["message"] = "Sorry " + ex.Message; return(View()); } }