Example #1
0
        public ActionResult Create(RoleEntry model)
        {
            var info = _role.GetByCode(model.RoleCode);

            if (info != null && info.RoleCode == model.RoleCode)
            {
                ModelState.AddModelError("RoleCode", string.Format("{0} has been used, please change one.", "Action Code"));
            }

            if (ModelState.IsValid)
            {
                model.CreatedBy   = Utility.CurrentUserName;
                model.CreatedTime = DateTime.UtcNow;
                Utility.Operate(this, Operations.Add, () =>
                {
                    _cache.Remove(Constants.CACHE_KEY_ROLES);
                    return(_role.Add(model));
                }, model.DisplayName);
            }
            else
            {
                Utility.SetErrorModelState(this);
            }

            return(Redirect("~/Admin/Roles/Index"));
        }
Example #2
0
        public IActionResult AddRole(Role role)
        {
            var checkPerson = _roleRepo.Read(role.Id);

            if (checkPerson == null)
            {
                _roleRepo.Add(role);
                return RedirectToAction("Index", "Roles");
            }
            return View();
        }
Example #3
0
 public ActionResult Create(Role role)
 {
     if (getCurrentUser() == null)
     {
         return(RedirectToAction("Index", "Login"));
     }
     else
     {
         try
         {
             role.r_active_yn = "Y";
             role.r_cre_by    = getCurrentUser().u_id;
             role.r_cre_date  = DateTime.Now;
             irole.Add(role);
             return(RedirectToAction(nameof(Index)));
         }
         catch
         {
             return(View());
         }
     }
 }
Example #4
0
 public IActionResult Save(RoleViewModel model)
 {
     if (ModelState.IsValid)
     {
         var department = new Role
         {
             Id          = model.Id,
             Description = model.Description,
         };
         if (model.Id.ToString().Length <= 0)
         {
             _Role.Add(department);
         }
         else
         {
             _Role.Update(department);
         }
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View());
     }
 }
Example #5
0
        /// <summary>
        /// create a new role
        /// </summary>
        /// <param name="entity">ApplicationRole</param>
        /// <returns>notification object {messagge = "carry the message to communicate to the user", Success = true or false}</returns>

        public Notification Add(RoleViewModel entity)
        {
            return(_role.Add(entity));
        }
Example #6
0
 public virtual void Add(bool addAll = false, Infastructure.ProgressReporter pg = null)
 {
     _role.Add(addAll, pg);
 }
Example #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(Library.Model.Role model)
 {
     return(dal.Add(model));
 }
Example #8
0
 public void Add(Role objRole)
 {
     Roleobj.Add(objRole);
 }
Example #9
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(E_Model.Role model)
 {
     return(dal.Add(model));
 }