コード例 #1
0
        public ActionResult Create(PromotionCreateModel promotion)
        {
            String[] stringList = new String[50];
            try
            {
                if (ModelState.IsValid)
                {
                    if (!String.IsNullOrEmpty(promotion.Tags))
                    {
                         stringList = promotion.Tags.Split(',');

                    }

                    using (var unitOfWork = new UnitOfWork())
                    {
                        var promId = unitOfWork.InsertPromotionDetailsByUsername(promotion.Price,promotion.Description,promotion.StartDate,promotion.EndDate,User.Identity.Name);
                        if (promId.HasValue)
                        {
                            foreach (var s in stringList.ToList())
                            {
                                if (!String.IsNullOrEmpty(s))
                                {
                                    var tag = s.Trim();
                                    unitOfWork.InsertPromotionTag(promId, tag);
                                }

                            }
                        }

                    }

                }

                    return RedirectToAction("Index");
            }
            catch(Exception ex)
            {
                return View();
            }
        }
コード例 #2
0
        // GET: Promotion/Create
        public ActionResult Create()
        {
            var promotion = new PromotionCreateModel();

            return View(promotion);
        }