public ActionResult CreateNewCreative(string ReturnUrl) { CreativeViewModel model = new CreativeViewModel(); ViewBag.Categories = GetCategoriesAsSelectList(); ViewBag.ReturnUrl = ReturnUrl; return View(model); }
public ActionResult CreateNewCreative(CreativeViewModel model, string ReturnUrl) { if (ModelState.IsValid) { var currentUserId = User.Identity.GetUserId(); model.UserId = currentUserId; model.DateAdded = DateTime.Now; Creative entity = Mapper.Map<Creative>(model); //mainContext.Creatives.Add(entity); //mainContext.SaveChanges(); creativeRepository.Add(entity); creativeRepository.Save(); return Redirect(ReturnUrl); } return View(model); }