BExIS.Web.Shell.Areas.DDM.Controllers.AdminController.ValidateSourceName C# (CSharp) Method

ValidateSourceName() private method

private ValidateSourceName ( string sourceName, long id ) : System.Web.Mvc.JsonResult
sourceName string
id long
return System.Web.Mvc.JsonResult
        public JsonResult ValidateSourceName(string sourceName, long id)
        {
            List<SearchAttributeViewModel> list = (List<SearchAttributeViewModel>)Session["searchAttributeList"];

            if (list != null)
            {
                foreach(SearchAttributeViewModel sa in list )
                {
                    if (sa.sourceName.ToLower().Equals(sourceName.ToLower()) && sa.id != id)
                    {
                        string error = String.Format(CultureInfo.InvariantCulture, "Source name already exists.", sourceName);

                        return Json(error, JsonRequestBehavior.AllowGet);
                    }
                }

                return Json(true, JsonRequestBehavior.AllowGet);

            }
            else
            {
                string error = String.Format(CultureInfo.InvariantCulture, "Is not possible to compare Sourcename with a empty list of search attributes.", sourceName);

                return Json(error, JsonRequestBehavior.AllowGet);
            }
        }