コード例 #1
0
        public ActionResult SubmitCreateAction(IFormCollection collection)
        {
            // Get Post Params Here
            if (ModelState.IsValid)
            {
                int     cardId    = Convert.ToInt32(collection["Advertisements.CardId"]);
                int     quantity  = Convert.ToInt32(collection["Advertisements.Quantity"]);
                decimal price     = Convert.ToInt32(collection["Advertisements.Price"]);
                string  accountId = HttpContext.Session.GetString("username");


                Advertisement ad = new Advertisement {
                    Price = price, Quantity = quantity, AccountId = accountId, CardId = cardId
                };
                _advertisementRepository.AddAdvertisment(ad);

                TempData["success"] = "Advertisement has been added succesfully";
                return(RedirectToAction("userAdList", "Advertisement"));
            }
            //Account id session
            //public int CardId =
            // card = _cardRepository.

            return(View());
        }