コード例 #1
0
 // 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();
 }
コード例 #2
0
 // 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);
 }
コード例 #3
0
        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));
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        // 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);
        }
コード例 #6
0
 // 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);
 }
コード例 #7
0
        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);
        }
コード例 #8
0
 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);
 }
コード例 #9
0
        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;
                }
            }
        }
コード例 #10
0
        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));
        }
コード例 #11
0
        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));
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        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));
        }
コード例 #14
0
        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 } };
        }
コード例 #15
0
        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));
        }
コード例 #16
0
 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);
 }
コード例 #17
0
 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");
 }
コード例 #18
0
        public double GetHighestBidOnAuction(int auctionId)
        {
            IAuctionService aSClient = new AuctionServiceClient("BasicHttpBinding_IAuctionService");

            return(aSClient.GetMaxBidOnAuction(auctionId));
        }
コード例 #19
0
        //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));
        }
コード例 #20
0
        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();
        }
コード例 #21
0
        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);
        }
コード例 #22
0
 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);
 }