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(); } }
// GET: Promotion/Create public ActionResult Create() { var promotion = new PromotionCreateModel(); return View(promotion); }