示例#1
0
        public async Task <bool> Add(Company company)
        {
            //Company.Pid=Company.Pid == 0 ? null : Company.Pid;
            using (var tran = db.Database.BeginTransaction())
            {
                try
                {
                    company.Isdel = false;
                    db.Company.Add(company);
                    await db.SaveChangesAsync();

                    db.CompanyLog.Add(new CompanyLog()
                    {
                        UpdateTime = DateTime.Now,
                        Cid        = company.Id,
                        Content    = "添加公司"
                    });;
                    await db.SaveChangesAsync();

                    await tran.CommitAsync();

                    return(true);
                }
                catch (Exception ex)
                {
                    await tran.RollbackAsync();

                    throw ex;
                }
            }
        }
示例#2
0
 public async Task <int> AddOrEdit(Employee employee)
 {
     if (employee.Id == 0)
     {
         await Add(employee);
     }
     else
     {
         await Edit(employee);
     }
     return(await db.SaveChangesAsync());
 }
示例#3
0
        private async Task <int> ChangePoweRole(int rId, int[] pId)
        {
            var rp = await db.RolePower.Where(x => x.RoleId == rId).ToListAsync();

            var rpIds  = rp.Select(x => x.PowerId).ToList();
            var delRps = rp.Where(x => !pId.Contains(x.PowerId)).ToList();

            db.RemoveRange(delRps);
            var addRps = pId.Where(x => !rpIds.Contains(x)).Select(x => new RolePower()
            {
                RoleId = rId, PowerId = x
            }).ToList();
            await db.AddRangeAsync(addRps);

            return(await db.SaveChangesAsync());
        }
示例#4
0
        private async Task <int> AddAsync(Power power)
        {
            await db.Power.AddAsync(power);

            return(await db.SaveChangesAsync());
        }
示例#5
0
        private async Task <int> Add(Department department)
        {
            await db.Department.AddAsync(department);

            return(await db.SaveChangesAsync());
        }
示例#6
0
        public async Task <int> Add(Operation Operation)
        {
            await db.Operation.AddAsync(Operation);

            return(await db.SaveChangesAsync());
        }
示例#7
0
 public async Task <int> Add(Menu menu)
 {
     db.Menu.Add(menu);
     return(await db.SaveChangesAsync());
 }
示例#8
0
        public async Task <int> Add(EmpGroup EmpGroup)
        {
            await db.EmpGroup.AddAsync(EmpGroup);

            return(await db.SaveChangesAsync());
        }
示例#9
0
        public async Task <int> Add(Position position)
        {
            await db.Position.AddAsync(position);

            return(await db.SaveChangesAsync());
        }