Ejemplo n.º 1
0
 /// <summary>
 /// 更新账户
 /// </summary>
 /// <param name="account"></param>
 /// <returns></returns>
 public int UpdateAdmin(AdminEntity account)
 {
     try
     {
         if (account == null)
         {
             return(-1);
         }
         using (var context = new DContext())
         {
             var dbAccount = context.Admins.Where(q => q.ID == account.ID).FirstOrDefault();
             if (dbAccount == null)
             {
                 return(-1);
             }
             dbAccount.Name       = account.Name;
             dbAccount.Password   = account.Password;
             dbAccount.UpdaedDate = DateTime.Now;
             context.SaveChanges();
             return(account.ID);
         }
     }
     catch (Exception ex)
     {
         return(-1);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 添加权限
 /// </summary>
 /// <param name="role"></param>
 /// <returns></returns>
 public int AddPermission(PermissionEntity permission)
 {
     try
     {
         if (permission == null)
         {
             return(-1);
         }
         using (var context = new DContext())
         {
             context.Permissions.Add(permission);
             context.SaveChanges();
             return(permission.ID);
         }
     }
     catch (Exception ex)
     {
         return(-1);
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 添加角色
 /// </summary>
 /// <param name="role"></param>
 /// <returns></returns>
 public int AddRole(RoleEntity role)
 {
     try
     {
         if (role == null)
         {
             return(-1);
         }
         using (var context = new DContext())
         {
             context.Roles.Add(role);
             context.SaveChanges();
             return(role.ID);
         }
     }
     catch (Exception ex)
     {
         return(-1);
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 添加账户
 /// </summary>
 /// <param name="account"></param>
 /// <returns></returns>
 public int AddAdmin(AdminEntity account)
 {
     try
     {
         if (account == null)
         {
             return(-1);
         }
         using (var context = new DContext())
         {
             context.Admins.Add(account);
             context.SaveChanges();
             return(account.ID);
         }
     }
     catch (Exception ex)
     {
         return(-1);
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 添加用户
 /// </summary>
 /// <param name="user"></param>
 /// <returns></returns>
 public int AddUser(AccountUser user)
 {
     try
     {
         if (user == null)
         {
             return(-1);
         }
         using (var context = new DContext())
         {
             context.AccountUsers.Add(user);
             context.SaveChanges();
             return(user.AccountUserId);
         }
     }
     catch (Exception ex)
     {
         return(-1);
     }
 }