public ActionResult Category_add(ETCategory Category) { TempData["messagealert"] = string.Empty; ViewBag.messagealert = string.Empty; if (ModelState.IsValid) { if (Category != null) { if (repCategory.CategoryIsExist(Category.CategoryName, 0)) { ViewBag.messagealert = "Category already exist"; ViewBag.Source = repCategory.getSourceType(); return(View(Category)); } else { Category.UserID = Convert.ToInt64(Session["UserID"]); Category.CreatedBy = Convert.ToInt64(Session["UserID"]); Category.CreatedDate = DateTime.Now; Category.ModifiedBy = Convert.ToInt64(Session["UserID"]); Category.ModifiedDate = DateTime.Now; dbEntities.ETCategories.Add(Category); dbEntities.SaveChanges(); if (Category.CategoryID != 0) { TempData["messagealert"] = Status.Save; } } } return(RedirectToAction("Index", "Category")); } return(View()); }