// GET: Auction/Create public ActionResult Create() { var proxy = new AuctionServiceClient("BasicHttpBinding_IAuctionService"); proxy.Open(); ViewBag.CategoryId = new SelectList(proxy.GetAllCategories(), "Id", "Name"); proxy.Close(); return View(); }
// GET: Auction/Create public ActionResult WinAution() { ApplicationDbContext db = new ApplicationDbContext(); var email = db.Users.Where(e => e.UserName == User.Identity.Name).FirstOrDefault().Email; var proxy = new AuctionServiceClient("BasicHttpBinding_IAuctionService"); proxy.Open(); var items = proxy.GetMyWonAuctionsHistory(email); proxy.Close(); db.Dispose(); return View(items); }
public bool InsertPictures(List <Image> images) { IAuctionService aSClient = new AuctionServiceClient("BasicHttpBinding_IAuctionService_Streaming"); ConvertDataModel converter = new ConvertDataModel(); // Convert to old array for sending over WCF. ImageData[] imageData = converter.ConvertFromImagesToImageData(images); return(aSClient.InsertPictures(imageData)); }
public ActionResult Special(string Id) { var keyword = Request["keyword"]; ViewBag.Type = Id; List<Auction> items; var proxy = new AuctionServiceClient("BasicHttpBinding_IAuctionService"); proxy.Open(); items = proxy.GetTopPriceAuctionsByCategory(Id, 0, 100).ToList(); ViewData["groups"] = proxy.GetAllCategories().Select(e => e.Name).ToList(); proxy.Close(); return View(items); }
// GET: Auction public ActionResult Index() { List<Auction> items; var proxy = new AuctionServiceClient("BasicHttpBinding_IAuctionService"); proxy.Open(); ApplicationDbContext db = new ApplicationDbContext(); var email = db.Users.Where(e => e.UserName == User.Identity.Name).FirstOrDefault().Email; items = proxy.GetMyAuctions(email).ToList(); ViewData["groups"] = proxy.GetAllCategories().Select(e => e.Name).ToList(); proxy.Close(); db.Dispose(); return View(items); }
// GET: Auction/Details/5 public ActionResult Details(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } var proxy = new AuctionServiceClient("BasicHttpBinding_IAuctionService"); proxy.Open(); Auction auction = proxy.GetAuction(id.Value); proxy.Close(); if (auction == null) { return HttpNotFound(); } return View(auction); }
public bool InsertAuction(CreateAuction createAuction) { IAuctionService aSClient = new AuctionServiceClient("BasicHttpBinding_IAuctionService"); ConvertDataModel converter = new ConvertDataModel(); bool confirmed = false; int id = aSClient.InsertAuction(converter.ConvertFromCreateAuctionToAuctionData(createAuction)); if (id != -1) { confirmed = true; } return(confirmed); }
public ActionResult Detail(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } var proxy = new AuctionServiceClient("BasicHttpBinding_IAuctionService"); proxy.Open(); Auction auction = proxy.GetAuction(id.Value); List<Auction> relativeAutions = proxy.GetOpenAuctionsByUser(auction.Owner.Email, 0, 10).ToList(); proxy.Close(); if (auction == null) { return HttpNotFound(); } ViewData["OtherAutions"] = relativeAutions; return View(auction); }
public void Run() { // Reference: Service References > AuctionService (Discovered from WcfPrøveEksamen project (Service) _auctionService = new AuctionServiceClient(); Console.WriteLine("Welcome to Patrick's Auctions"); bool running = true; while (running) { Console.WriteLine("To see all current auctions, press 1"); Console.WriteLine("To see specific auction, press 2"); Console.WriteLine("To offer on a product, press 3"); Console.WriteLine("To (q)uit, press q"); var input = Console.ReadLine(); switch (input?.ToLower()) { case "1": PrintAllAuctions(); break; case "2": PrintAllProducts(); break; case "3": BidOnProduct(); break; case "q": Console.WriteLine("Thanks for using Patrick's Auctionhouse"); running = false; break; default: Console.WriteLine("Command not understood"); break; } } }
public ActionResult RecordCount() { dynamic count = 0; try { if (ModelState.IsValid) { AuctionServiceClient service = new AuctionServiceClient(); count = service.RecordCount(); } } catch (Exception e) { ModelState.AddModelError("error", "Something went wrong"); count = null; throw e; } return(Json(new { count }, JsonRequestBehavior.AllowGet)); }
public ActionResult GetAuctionListDataBYAuctionDate(DateTime date) { dynamic listVehicle = 0; try { if (ModelState.IsValid) { AuctionServiceClient service = new AuctionServiceClient(); listVehicle = service.GetAuctionListDataBYAuctionDate(date); } } catch (Exception e) { ModelState.AddModelError("error", "Something went wrong"); listVehicle = null; throw e; } return(Json(new { listVehicle }, JsonRequestBehavior.AllowGet)); }
public ActionResult Create([Bind(Include = "Id,BestBid,Description,Name,PhotoUrl,Price")] Auction auction) { if (ModelState.IsValid) { ApplicationDbContext db = new ApplicationDbContext(); var email = db.Users.Where(e => e.UserName == User.Identity.Name).FirstOrDefault().Email; var proxy = new AuctionServiceClient("BasicHttpBinding_IAuctionService"); proxy.Open(); var cateId = int.Parse(Request["CategoryId"]); auction.CategoryId = cateId; auction.StartTime = DateTime.Now; auction.EndTime = DateTime.Now; auction.AutionStatus = AuctionStatus.New; proxy.AddNewAuction(email, auction); proxy.Close(); return RedirectToAction("Index"); } return View(auction); }
public ActionResult GetAuctionFrontEndID() { dynamic AuctionID = 0; try { if (ModelState.IsValid) { AuctionServiceClient service = new AuctionServiceClient(); AuctionID = service.AuctionFrontEndID(); //return Json(AuctionID, JsonRequestBehavior.AllowGet); } } // Please through Exeption Everywhere catch (Exception e) { ModelState.AddModelError("error", "Something Wrong"); AuctionID = null; throw e; } return(Json(AuctionID, JsonRequestBehavior.AllowGet)); }
public ActionResult DeleteAuction(DateTime AucDate) { bool status = false; try { if (ModelState.IsValid) { AuctionServiceClient auctionServiceClient = new AuctionServiceClient(); status = auctionServiceClient.Delete(AucDate); return(RedirectToAction("Index")); } } catch (Exception e) { ModelState.AddModelError("error", "Something Went Wrong!"); status = false; throw e; } return(View()); //return new JsonResult { Data = new { status = status } }; }
public ActionResult GenerateAuctionListPDF(int auctionFrntID) { //List<Vehicles> vehicles = new List<Vehicles>(); dynamic vehicles = 0; try { if (ModelState.IsValid) { AuctionServiceClient service = new AuctionServiceClient(); vehicles = service.GetVehiclesForPDF(auctionFrntID); } } // Please through Exeption Everywhere catch (Exception e) { ModelState.AddModelError("error", "Something Wrong"); vehicles = null; throw e; } return(Json(vehicles, JsonRequestBehavior.AllowGet)); }
public ActionResult Comment(string returnUrl) { var autionId = int.Parse(Request["Id"]); if (User.Identity.IsAuthenticated) { ApplicationDbContext db = new ApplicationDbContext(); var email = db.Users.Where(e => e.UserName == User.Identity.Name).FirstOrDefault().Email; var cmt = Request["Comment"]; var proxy = new AuctionServiceClient("BasicHttpBinding_IAuctionService"); proxy.Open(); proxy.Comment(email, autionId, cmt); proxy.Close(); } return Redirect(returnUrl); }
public ActionResult Start() { ApplicationDbContext db = new ApplicationDbContext(); var email = db.Users.Where(e => e.UserName == User.Identity.Name).FirstOrDefault().Email; var startTime = DateTime.Parse(Request["StartTime"]); var endTime = DateTime.Parse(Request["EndTime"]); var id = int.Parse(Request["Id"]); var proxy = new AuctionServiceClient("BasicHttpBinding_IAuctionService"); proxy.Open(); proxy.StartAuction(email, id, startTime, endTime); proxy.Close(); db.Dispose(); return RedirectToAction("Index"); }
public double GetHighestBidOnAuction(int auctionId) { IAuctionService aSClient = new AuctionServiceClient("BasicHttpBinding_IAuctionService"); return(aSClient.GetMaxBidOnAuction(auctionId)); }
//for test purposes for now. public void CreateAuction(AuctionModel auctionModel, UserModel userModel) { using (AuctionServiceClient proxy = new AuctionServiceClient("BasicHttpBinding_IAuctionService")) proxy.InsertAuction(AuctionUtility.ConvertAuctionModelToAuctionData(auctionModel, userModel)); }
static void Main(string[] args) { AuctionService.AuctionServiceClient auctionservice = new AuctionServiceClient(); Console.WriteLine("Velkommen til Patrick's Auktion"); bool running = true; while (running) { Console.WriteLine("For at se alle auktioner igang, tryk 1"); Console.WriteLine("For at finde en bestemt vare, tryk 2"); Console.WriteLine("For at give et bud, tryk 3"); Console.WriteLine("For at afslute, tryk Q"); string input = Console.ReadLine(); if (input == "1") { var auctions = auctionservice.GetAuctions().ToList(); foreach (var auction in auctions) { Console.WriteLine("Auction: #"+auction.Varenummer+" \n "+auction.Varebetegnelse+" - $"+auction.BudPris); } } else if (input == "2") { Console.WriteLine("Skriv varenummeret for at finde auktionen"); string auctioninput = Console.ReadLine(); var auction = auctionservice.GetAuction(auctioninput); if (auction != null) { Console.WriteLine("Auction: #" + auction.Varenummer + " \n " + auction.Varebetegnelse + " - $" + auction.BudPris + " ("+auction.BudKundeNavn+")"); } else { Console.WriteLine("Kunne ikke finde auktion - går tilbage til menu"); } } else if (input == "3") { Console.WriteLine("Skriv et varenummer du vil byde på"); string varenummerinput = Console.ReadLine(); Console.WriteLine("Skriv det bud du vil afgive på auktionen"); string offerinput = Console.ReadLine(); int offer = 0; int.TryParse(offerinput, out offer); if (offer > 0) { Console.WriteLine("Skriv venligst dit navn"); string consumername = Console.ReadLine(); Console.WriteLine(".. og dit nummer"); string consumernumber = Console.ReadLine(); string answer = auctionservice.Bid(varenummerinput, offer, consumername, consumernumber); // Her kunne man have en switch med de forskellige svar der kom og så håndtere dem for brugeren Console.WriteLine(answer); } else { Console.WriteLine("Bud ikke gyldigt - går tilbage til menuen"); } } else if (input == "Q") { Console.WriteLine("Tak fordi du brugte Patrick's auktionshus"); running = false; } else { Console.WriteLine("Kommando ikke forstået - prøv igen"); } } Console.ReadKey(); }
public async Task<ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.UserName, PhoneNumber = model.PhoneNumber, Email = model.Email}; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { // Call service to register with auction service database var proxy = new AuctionServiceClient("BasicHttpBinding_IAuctionService"); proxy.Open(); await proxy.AddServiceUserAsync(new Services.Models.User() { UserName = user.UserName, Email = user.Email, PhoneNumber = user.PhoneNumber }); proxy.Close(); // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); string msg = "Bạn đã đăng ký tài khoản tại SGUStore<br/>Vui lòng hoàn tất việc đăng ký của bạn <a href=\"" + callbackUrl + "\">tại đây</a>"; await UserManager.SendEmailAsync(user.Id, "SGUStore - Xác nhận đăng ký", msg); return RedirectToAction("Confirm", new { Email = user.Email }); } AddErrors(result); } // If we got this far, something failed, redisplay form return View(model); }
public ActionResult Bid(string returnUrl) { var autionId = int.Parse(Request["Id"]); var user = Request["User"]; var status = false; if (User.Identity.IsAuthenticated) { ApplicationDbContext db = new ApplicationDbContext(); var email = db.Users.Where(e => e.UserName == user).FirstOrDefault().Email; var price = int.Parse(Request["Price"]); var proxy = new AuctionServiceClient("BasicHttpBinding_IAuctionService"); proxy.Open(); status = proxy.Bid(email, price, autionId); proxy.Close(); } return Redirect(returnUrl); }