コード例 #1
0
 public ActionResult Edit(Guid UserId, Guid RoleId, Models.aspnet_UsersInRolesView collection)
 {
     try
     {
         int outputId = _dataobject.Update(collection);
         return(RedirectToAction(this.ActionReturn()));
     }
     catch (Exception ex)
     {
         Services.GlobalErrors.Parse(ModelState, _dataobject.Errors, ex);
         return(PartialView(this._updateview, collection));
     }
 }
コード例 #2
0
        public int Update(Models.aspnet_UsersInRolesView data)
        {
            try
            {
                //this.Validate(data);
                //var updatedata = GetById2(data.UserId, data.RoleId);

                ////this._db.Entry(data).State = System.Data.Entity.EntityState.Modified;
                //this._db.SaveChanges();
                return(0);
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #3
0
        public int Insert(Models.aspnet_UsersInRolesView data)
        {
            try
            {
                this.Validate(data);

                if (Roles.IsUserInRole(data.UserName, data.RoleName))
                {
                    throw new InvalidOperationException("Phân quyền đã tồn tại.");
                }

                var adddata = new Models.aspnet_UsersInRoles();
                adddata.RoleId = data.RoleId;
                adddata.UserId = data.UserId;
                this._db.aspnet_UsersInRoles.Add(adddata);
                this._db.SaveChanges();
                return(0);
            }
            catch (Exception)
            {
                throw;
            }
        }