public ActionResult Create(QuickURLSubmitModel model) { ModelState.Remove("MyUser.Password"); ModelState.Remove("MyUser.ConfirmPassword"); ModelState.Remove("MyUrl.UrlDesc"); if (!ModelState.IsValid) { ViewBag.CategoryId = new SelectList(objBs.categoryBs.GetAll().ToList(), "CategoryId", "CategoryName"); return View("Index"); } try { objBs.InsertQuickURL(model); TempData["Msg"] = "Created Successfully"; } catch(DbEntityValidationException exception) { TempData["Msg"] = "Create Failed : " + exception.Message; } catch(Exception exception) { TempData["Msg"] = "Create Failed : " + exception.Message; } return RedirectToAction("Index"); }
public void InsertQuickURL(QuickURLSubmitModel model) { using (TransactionScope trans = new TransactionScope()) { try { tbl_User user = model.MyUser; user.Password = user.ConfirmPassword = "******"; user.Role = "U"; userBs.Insert(user); tbl_Url url = model.MyUrl; url.UserId = user.UserId; url.UrlDesc = url.UrlTitle; url.IsApproved = "P"; urlBs.Insert(url); trans.Complete(); } catch (Exception exception) { throw new Exception(exception.Message); } } }
public ActionResult Create(QuickURLSubmitModel quickUrl) { ModelState.Remove("MyUser.Password"); ModelState.Remove("MyUser.ConfirmPassword"); ModelState.Remove("MyUrl.UrlDesc"); if (!ModelState.IsValid) { ViewBag.CategoryId = CategoryList; return View("Index"); } TempData["Resp"] = AreaBs.UrlBs.InsertQuickURL(quickUrl); return RedirectToAction("Index"); }