示例#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"));
        }
示例#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();
        }
示例#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());
         }
     }
 }
示例#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());
     }
 }
示例#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));
        }
示例#6
0
 public virtual void Add(bool addAll = false, Infastructure.ProgressReporter pg = null)
 {
     _role.Add(addAll, pg);
 }
示例#7
0
文件: RoleService.cs 项目: Dekai/zdk
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(Library.Model.Role model)
 {
     return(dal.Add(model));
 }
示例#8
0
 public void Add(Role objRole)
 {
     Roleobj.Add(objRole);
 }
示例#9
0
文件: Role.cs 项目: kencentre/X-Wcf
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(E_Model.Role model)
 {
     return(dal.Add(model));
 }