Пример #1
0
        public ActionResult Create(UserAccessViewModel objEntity)
        {
            UserAccessRepository objUserAccessRepository = new UserAccessRepository();

            if (ModelState.IsValid)
            {
                objEntity.UserAccessTitle = objEntity.UserAccessTitle.Trim();
                objEntity.Url             = objEntity.Url.Trim();
                objEntity.CssClass        = objEntity.CssClass.Trim();

                objEntity.CreatedBy = 1;//admin

                objEntity = objUserAccessRepository.Insert(objEntity);


                if (objEntity.Result == ResultFlags.Success.GetHashCode())
                {
                    //   Install-Package MvcFlashMessages
                    this.Flash("Success", "User Access Insert successfully");

                    return(RedirectToAction("Index"));
                }
                else if (objEntity.Result == ResultFlags.Failure.GetHashCode())
                {
                    this.Flash("Error", "Failed to Insert UserAccess");
                    return(RedirectToAction("Index"));
                }
                else if (objEntity.Result == ResultFlags.Duplicate.GetHashCode())
                {
                    this.Flash("Warning", "UserAccess Name is Already Exist");
                    return(RedirectToAction("Index"));
                }
            }
            return(View(objEntity));
        }