// GET: Buyers/Create public ActionResult CreateAddress(int?id, Address model) { if (ModelState.IsValid) { try { //Call Post Method Address objec = APIMethods.APIPost <Address>(model, "Addresses"); BuyerAddress bAdd = new BuyerAddress(); bAdd.AddressID = objec.AddressID; bAdd.UserID = User.Identity.GetUserId(); APIMethods.APIPost <BuyerAddress>(bAdd, "BuyerAddresses"); if (id != 0) { return(RedirectToAction("Detailss", "home", new { id = id })); } return(RedirectToAction("Index")); } catch (Exception E) { throw new Exception("Something went wrong. Please try again"); } } else { return(View()); } }
public ActionResult Create(ViewBuyer vbuyer) { if (ModelState.IsValid) { BuyerAddress address = new BuyerAddress(); address.Area = areaRepo.Get(vbuyer.Area); address.City = cityRepo.Get(vbuyer.City); address.Block = vbuyer.Block; address.House = vbuyer.House; address.Road = vbuyer.House; BuyerLogin login = new BuyerLogin(); login.Username = vbuyer.Username; login.Password = vbuyer.Password; BuyerApproval approval = new BuyerApproval(); approval.Status = false; Buyer buyer = new Buyer(); buyer.FirstName = vbuyer.FirstName; buyer.LastName = vbuyer.LastName; buyer.Email = vbuyer.Email; buyer.Phone = vbuyer.Phone; buyer.Gender = vbuyer.Gender; buyer.Address = address; buyer.LoginData = login; buyer.Approval = approval; buyerRepo.Insert(buyer); return(RedirectToAction("Index", "Home")); } return(View(vbuyer)); }
public async Task <IHttpActionResult> GetBuyerAddress(int id) { BuyerAddress objct = await db.BuyerAddresses.FindAsync(id); if (objct == null) { return(NotFound()); } BuyerAddressNoR newObject = new BuyerAddressNoR() { // Bids= objct.Bids, // BankApproval = objct.BankApproval, AddressID = objct.AddressID, id = objct.id, // Guarintee = objct.Guarintee, // Auction = objct.Auction, // Property = objct.Property, // RegisteredBuyer = objct.RegisteredBuyer, UserID = objct.UserID, // ConcludedAuctions = objct.ConcludedAuctions, // PropertyID = objct.PropertyID, // RegisteredBuyer = objct.RegisteredBuyer, // TimeOfbid = objct.TimeOfbid //Seller = objct.Seller // AuctionRegistration = fee.AuctionRegistration }; return(Ok(newObject)); }
public bool AddBuyerAddress(BuyerAddressDTO addressDTO, int customerId) { //TODO:Server side validation. try { BuyerAddress addressObj = new BuyerAddress(); addressObj.User = customerId; addressObj.State = addressDTO.State; addressObj.City = addressDTO.City; addressObj.Address1 = addressDTO.Address1; addressObj.Address2 = addressDTO.Address2; addressObj.PostalCode = addressDTO.PostalCode; addressObj.PhoneNumber = addressDTO.PhoneNumber; addressObj.CreatedOnUtc = DateTime.UtcNow; addressObj.UpdatedOnUtc = DateTime.UtcNow; this.context.Entry(addressObj).State = EntityState.Added; var changes = context.SaveChanges(); if (changes > 0) { return(true); } } catch { } return(false); }
private void AddBuyer() { Buyer Buyer = new Buyer(); Buyer.FirstName = "Nahid"; Buyer.LastName = "Nawaz"; BuyerAddress address = new BuyerAddress() { House = "06", Road = "05", Block = null, Area = new Area() { Name = "Gulshan" }, City = new City() { Name = "Khulna" } }; Buyer.Email = "*****@*****.**"; Buyer.Phone = "01711829603"; Buyer.Gender = "Male"; Buyer.LoginData = new BuyerLogin { Username = "******", Password = "******" }; Buyer.Approval = new BuyerApproval(); Buyer.Approval.Status = true; context.Buyers.Add(Buyer); }
public async Task <IHttpActionResult> PutBuyerAddress(int id, BuyerAddress buyerAddress) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != buyerAddress.id) { return(BadRequest()); } db.Entry(buyerAddress).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BuyerAddressExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult DeleteConfirmed(int id) { BuyerAddress buyerAddress = db.BuyerAddresses.Find(id); db.BuyerAddresses.Remove(buyerAddress); db.SaveChanges(); return(RedirectToAction("Index")); }
public int Delete(int id) { BuyerAddress addressToDelete = context.BuyerAddresses.SingleOrDefault(a => a.Id == id); context.BuyerAddresses.Remove(addressToDelete); return(context.SaveChanges()); }
public async Task <ActionResult> DeleteConfirmed(int id) { BuyerAddress buyerAddress = await db.BuyerAddresses.FindAsync(id); db.BuyerAddresses.Remove(buyerAddress); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task PatchMeAddress(string addressID, BuyerAddress patch, VerifiedUserContext user) { var current = await new OrderCloudClientWithContext(user).Me.GetAddressAsync <BuyerAddress>(addressID); var patched = PatchHelper.PatchObject(patch, current); await ValidateAddress(patched); await new OrderCloudClientWithContext(user).Me.PatchAddressAsync(addressID, (PartialBuyerAddress)patch); }
public async Task PatchMeAddress(string addressID, BuyerAddress patch, VerifiedUserContext user) { var current = await _oc.Me.GetAddressAsync <BuyerAddress>(addressID, user.AccessToken); var patched = PatchHelper.PatchObject(patch, current); await ValidateAddress(patched); await _oc.Me.PatchAddressAsync(addressID, (PartialBuyerAddress)patch, user.AccessToken); }
public async Task can_create_strongly_typed_xp() { var ba = new BuyerAddress <CustomXP> { xp = new CustomXP { Foo = "xyz", Bar = 123 } }; JsonAssert.AreEquivalent(new { Foo = "xyz", Bar = 123 }, ba.xp); }
public async Task PatchMeAddress(string addressID, BuyerAddress patch, DecodedToken decodedToken) { var current = await _oc.Me.GetAddressAsync <BuyerAddress>(addressID, decodedToken.AccessToken); var patched = PatchHelper.PatchObject(patch, current); await ValidateAddress(patched); await _oc.Me.PatchAddressAsync(addressID, (PartialBuyerAddress)patch, decodedToken.AccessToken); }
public async Task <IHttpActionResult> GetBuyerAddress(int id) { BuyerAddress buyerAddress = await db.BuyerAddresses.FindAsync(id); if (buyerAddress == null) { return(NotFound()); } return(Ok(buyerAddress)); }
public static BuyerAddress Map(Candidate candidate, BuyerAddress raw) { // break reference which was causing pass by reference error var rawCopy = JsonSerializer.Deserialize <BuyerAddress>(JsonSerializer.Serialize(raw)); rawCopy.Street1 = candidate.DeliveryLine1; rawCopy.Street2 = candidate.DeliveryLine2; rawCopy.City = candidate.Components.CityName; rawCopy.State = candidate.Components.State; rawCopy.Zip = $"{candidate.Components.ZipCode}-{candidate.Components.Plus4Code}"; return(rawCopy); }
public int Update(BuyerAddress address) { BuyerAddress addressToUpdate = context.BuyerAddresses.SingleOrDefault(a => a.Id == address.Id); addressToUpdate.Area = address.Area; addressToUpdate.City = address.City; addressToUpdate.Block = address.Block; addressToUpdate.House = address.House; addressToUpdate.Road = address.Road; return(context.SaveChanges()); }
public async Task <IHttpActionResult> PostBuyerAddress(BuyerAddress buyerAddress) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.BuyerAddresses.Add(buyerAddress); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = buyerAddress.id }, buyerAddress)); }
public ActionResult Edit([Bind(Include = "id,AddressID,UserID")] BuyerAddress buyerAddress) { if (ModelState.IsValid) { db.Entry(buyerAddress).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AddressID = new SelectList(db.Addresses, "AddressID", "Country", buyerAddress.AddressID); ViewBag.UserID = new SelectList(db.RegisteredBuyers, "UserId", "FirstName", buyerAddress.UserID); return(View(buyerAddress)); }
// GET: BuyerAddresses/Delete/5 public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BuyerAddress buyerAddress = await db.BuyerAddresses.FindAsync(id); if (buyerAddress == null) { return(HttpNotFound()); } return(View(buyerAddress)); }
public async Task <ActionResult> Create([Bind(Include = "id,AddressID,UserID")] BuyerAddress buyerAddress) { if (ModelState.IsValid) { db.BuyerAddresses.Add(buyerAddress); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.AddressID = new SelectList(db.Addresses, "AddressID", "Country", buyerAddress.AddressID); ViewBag.UserID = new SelectList(db.RegisteredBuyers, "UserId", "FirstName", buyerAddress.UserID); return(View(buyerAddress)); }
public async Task <IHttpActionResult> DeleteBuyerAddress(int id) { BuyerAddress buyerAddress = await db.BuyerAddresses.FindAsync(id); if (buyerAddress == null) { return(NotFound()); } db.BuyerAddresses.Remove(buyerAddress); await db.SaveChangesAsync(); return(Ok(buyerAddress)); }
// GET: BuyerAddresses/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BuyerAddress buyerAddress = db.BuyerAddresses.Find(id); if (buyerAddress == null) { return(HttpNotFound()); } return(View(buyerAddress)); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (TransactionID != null) { hashCode = hashCode * 59 + TransactionID.GetHashCode(); } if (BuyerFirstName != null) { hashCode = hashCode * 59 + BuyerFirstName.GetHashCode(); } if (BuyerLastName != null) { hashCode = hashCode * 59 + BuyerLastName.GetHashCode(); } if (BuyerAddress != null) { hashCode = hashCode * 59 + BuyerAddress.GetHashCode(); } if (BuyerCity != null) { hashCode = hashCode * 59 + BuyerCity.GetHashCode(); } if (BuyerEmail != null) { hashCode = hashCode * 59 + BuyerEmail.GetHashCode(); } if (BuyerUserId != null) { hashCode = hashCode * 59 + BuyerUserId.GetHashCode(); } if (PaymentStatus != null) { hashCode = hashCode * 59 + PaymentStatus.GetHashCode(); } if (PaymentReferenceId != null) { hashCode = hashCode * 59 + PaymentReferenceId.GetHashCode(); } if (TotalAmount != null) { hashCode = hashCode * 59 + TotalAmount.GetHashCode(); } return(hashCode); } }
public static Lookup MapToUSStreetLookup(BuyerAddress address) { var lookup = new Lookup() { Street = address.Street1, Street2 = address.Street2, City = address.City, State = address.State, ZipCode = address.Zip, MatchStrategy = Lookup.STRICT, MaxCandidates = 5 }; return(lookup); }
public static List <BuyerAddress> Map(AutoCompleteResponse response, BuyerAddress raw) { var addresses = response.suggestions.Select(suggestion => { var rawCopy = JsonSerializer.Deserialize <BuyerAddress>(JsonSerializer.Serialize(raw)); rawCopy.Street1 = suggestion.street_line; rawCopy.Street2 = suggestion.secondary; rawCopy.City = suggestion.city; rawCopy.State = suggestion.state; rawCopy.Zip = suggestion.zipcode; rawCopy.xp = null; return(rawCopy); }).ToList(); return(addresses); }
// GET: BuyerAddresses/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BuyerAddress buyerAddress = db.BuyerAddresses.Find(id); if (buyerAddress == null) { return(HttpNotFound()); } ViewBag.AddressID = new SelectList(db.Addresses, "AddressID", "Country", buyerAddress.AddressID); ViewBag.UserID = new SelectList(db.RegisteredBuyers, "UserId", "FirstName", buyerAddress.UserID); return(View(buyerAddress)); }
public async Task <BuyerAddressValidation> ValidateAddress(BuyerAddress address) { var response = new BuyerAddressValidation(address); if (address.Country == "US") { var lookup = BuyerAddressMapper.MapToUSStreetLookup(address); var candidate = await _service.ValidateSingleUSAddress(lookup); // Always seems to return 1 or 0 candidates if (candidate.Count > 0) { response.ValidAddress = BuyerAddressMapper.Map(candidate[0], address); response.GapBetweenRawAndValid = candidate[0].Analysis.DpvFootnotes; } else { // no valid address found var suggestions = await _service.USAutoCompletePro($"{address.Street1} {address.Street2}"); if (NoAddressSuggestions(suggestions)) { throw new InvalidBuyerAddressException(response); } response.SuggestedAddresses = BuyerAddressMapper.Map(suggestions, address); } if (!response.ValidAddressFound) { throw new InvalidBuyerAddressException(response); } } else { response.ValidAddress = address; } return(response); }
public int Insert(BuyerAddress address) { context.BuyerAddresses.Add(address); return(context.SaveChanges()); }
public BuyerAddressValidation(BuyerAddress raw) { RawAddress = raw; }
public async Task PatchMeAddress(string addressID, [FromBody] BuyerAddress patch) => await _command.PatchMeAddress(addressID, patch, VerifiedUserContext);