public async Task <IHttpActionResult> PostRegisteredBuyer(RegisteredBuyer registeredBuyer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.RegisteredBuyers.Add(registeredBuyer); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (RegisteredBuyerExists(registeredBuyer.UserId)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = registeredBuyer.UserId }, registeredBuyer)); }
// GET: Buyers public ActionResult Index(RegisteredBuyer model) { if (ModelState.IsValid) { return(View()); } else { try { RegisteredBuyer buyer = APIMethods.APIGet <RegisteredBuyer>(User.Identity.GetUserId(), "RegisteredBuyers"); return(View(buyer)); } catch (Exception E) { if (User.Identity.IsAuthenticated) { return(RedirectToAction("Create", "Buyers", new { id = 0 })); } else { return(RedirectToAction("Login", "Account")); } } } }
public async Task <IHttpActionResult> PutRegisteredBuyer(string id, RegisteredBuyer registeredBuyer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != registeredBuyer.UserId) { return(BadRequest()); } db.Entry(registeredBuyer).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RegisteredBuyerExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <ActionResult> DeleteConfirmed(string id) { RegisteredBuyer registeredBuyer = await db.RegisteredBuyers.FindAsync(id); db.RegisteredBuyers.Remove(registeredBuyer); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <IHttpActionResult> GetRegisteredBuyer(string id) { RegisteredBuyer registeredBuyer = await db.RegisteredBuyers.FindAsync(id); if (registeredBuyer == null) { return(NotFound()); } return(Ok(registeredBuyer)); }
public async Task <ActionResult> Edit([Bind(Include = "UserId,FirstName,LastName,IDNumber,DateOfBirth,ProfilePhotoPath,ProofOfResidencePath,CopyOfIDPath,ProofOfBankAccount,IDBuyerVerifyPhoto,ApprovalStatus,RegistrationDate,Signiture")] RegisteredBuyer registeredBuyer) { if (ModelState.IsValid) { db.Entry(registeredBuyer).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.UserId = new SelectList(db.Deposits, "BuyerID", "ProofOfPaymentPath", registeredBuyer.UserId); return(View(registeredBuyer)); }
public async Task <IHttpActionResult> DeleteRegisteredBuyer(string id) { RegisteredBuyer registeredBuyer = await db.RegisteredBuyers.FindAsync(id); if (registeredBuyer == null) { return(NotFound()); } db.RegisteredBuyers.Remove(registeredBuyer); await db.SaveChangesAsync(); return(Ok(registeredBuyer)); }
// GET: RegisteredBuyers/Details/5 public async Task <ActionResult> Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RegisteredBuyer registeredBuyer = await db.RegisteredBuyers.FindAsync(id); if (registeredBuyer == null) { return(HttpNotFound()); } return(View(registeredBuyer)); }
// GET: RegisteredBuyers/Edit/5 public async Task <ActionResult> Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RegisteredBuyer registeredBuyer = await db.RegisteredBuyers.FindAsync(id); if (registeredBuyer == null) { return(HttpNotFound()); } ViewBag.UserId = new SelectList(db.Deposits, "BuyerID", "ProofOfPaymentPath", registeredBuyer.UserId); return(View(registeredBuyer)); }
public void Bid3(string name, decimal bid, int auctionID, string userID) { // Call the broadcastMessage method to update clients. ICollection <Bid> bids = APILibrary.APIMethods.APIGetALL <ICollection <Bid> >("Bids"); RegisteredBuyer buyer = APILibrary.APIMethods.APIGetALL <RegisteredBuyer>("RegisteredBuyers"); Bid maxBid = new Bid(); bool first = true; foreach (Bid b in bids) { if (b.PropertyID == auctionID) { if (first) { maxBid = b; first = false; } else { if (b.AmuntOfBid > maxBid.AmuntOfBid) { maxBid = b; } } } } if (bid > maxBid.AmuntOfBid) { Bid newBid = new Bid() { BuyerID = userID, PropertyID = auctionID, TimeOfbid = DateTime.Now, AmuntOfBid = (decimal)bid }; Clients.All.broadcastMessage3(buyer.ProfilePhotoPath, name, bid); APILibrary.APIMethods.APIPost <Bid>(newBid, "Bids"); } else { return; } }
// GET: Buyers/Create public ActionResult Create(int?id, BuyerViewModel model) { model.UserId = User.Identity.GetUserId(); if (ModelState.IsValid) { try { RegisteredBuyer newData = new RegisteredBuyer { UserId = User.Identity.GetUserId(), FirstName = model.FirstName, LastName = model.LastName, IDNumber = model.IDNumber, DateOfBirth = model.DateOfBirth, Signiture = model.Signiture, RegistrationDate = DateTime.Now, }; newData.ProfilePhotoPath = FileController.PostFile(model.ProfilePhotoPath, "ProfilePhotos", "ProfilePhotos"); newData.ProofOfResidencePath = FileController.PostFile(model.ProofOfResidencePath, "ProofOfResedence", "ProofOfResedence"); newData.CopyOfIDPath = FileController.PostFile(model.CopyOfIDPath, "CopyOfIDPath", "CopyOfIDPath"); newData.IDBuyerVerifyPhoto = FileController.PostFile(model.IDBuyerVerifyPhoto, "IdBuyerVerifyPhoto", "IdBuyerVerifyPhoto"); newData.ProofOfBankAccount = FileController.PostFile(model.ProofOfBankAccount, "ProofOfBankAccount", "ProofOfBankAccount"); //Call Post Method RegisteredBuyer ob = APIMethods.APIPost <RegisteredBuyer>(newData, "RegisteredBuyers"); return(RedirectToAction("CreateAddress", "Buyers", new { id = id })); } catch (Exception E) { throw new Exception("Something went wrong. Please try again" + E.ToString()); } } else { return(View()); } }
public async Task <IHttpActionResult> GetRegisteredBuyer(string id) { RegisteredBuyer objct = await db.RegisteredBuyers.FindAsync(id); if (objct == null) { return(NotFound()); } RegisteredBuyerNoR newObject = new RegisteredBuyerNoR() { ApprovalStatus = objct.ApprovalStatus, // Deposit = objct.Deposit, // AuctionRegistrations = objct.AuctionRegistrations, // Bids = objct.Bids, // BuyerAddresses = objct.BuyerAddresses, FirstName = objct.FirstName, // ConcludedAuctions = objct.ConcludedAuctions, Signiture = objct.Signiture, // CopyOfIDPath = objct.DateOfBirth, DateOfBirth = objct.DateOfBirth, IDBuyerVerifyPhoto = objct.IDBuyerVerifyPhoto, LastName = objct.LastName, IDNumber = objct.IDNumber, ProfilePhotoPath = objct.ProfilePhotoPath, ProofOfBankAccount = objct.ProofOfBankAccount, ProofOfResidencePath = objct.ProofOfResidencePath, UserId = objct.UserId, RegistrationDate = objct.RegistrationDate }; try { DepositNoR newDep = new DepositNoR(); newDep.Amount = objct.Deposit.Amount; newDep.BuyerID = objct.Deposit.BuyerID; newDep.DateOfPayment = objct.Deposit.DateOfPayment; newDep.DepositReturned = objct.Deposit.DepositReturned; newDep.ProofOfPaymentPath = objct.Deposit.ProofOfPaymentPath; newDep.ProofOfReturnPayment = objct.Deposit.ProofOfReturnPayment; newObject.Deposit = newDep; } catch { } try { List <BuyerAddressNoR> lys = new List <BuyerAddressNoR>(); foreach (BuyerAddress bAdd in objct.BuyerAddresses) { BuyerAddressNoR newAdd = new BuyerAddressNoR(); newAdd.AddressID = bAdd.Address.AddressID; newAdd.id = bAdd.id; newAdd.UserID = bAdd.UserID; lys.Add(newAdd); } newObject.BuyerAddresses = lys; } catch { } return(Ok(newObject)); }