コード例 #1
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);
        }