示例#1
0
 public void AddUserOperationClaim(UserOperationClaim userOperationClaim)
 {
     using (var context = new CarContext())
     {
         var addedEntity = context.Entry(userOperationClaim);
         addedEntity.State = EntityState.Added;
         context.SaveChanges();
     }
 }
示例#2
0
        public async Task <bool> AddUserOperationClaimAsync(UserOperationClaim userOperationClaim)
        {
            using (ReCapContext context = new ReCapContext())
            {
                await context.UserOperationClaims.AddAsync(userOperationClaim);

                return(await context.SaveChangesAsync() > 0);
            }
        }
示例#3
0
 public void AddClaim(UserOperationClaim user)
 {
     using (var context = new UniAppContext())
     {
         var addClaim = context.Entry(user);
         addClaim.State = EntityState.Added;
         context.SaveChanges();
     }
 }
示例#4
0
        public void DeleteClaim(UserOperationClaim user)
        {
            var userClaim = GetClaimById(u => u.Id == user.Id);

            using (var context = new UniAppContext())
            {
                var deleteClaim = context.Entry(user);
                deleteClaim.State = EntityState.Deleted;
                context.SaveChanges();
            }
        }
示例#5
0
 // NOTE Maybe this should take an OperationClaim instead of a string?
 public void AddOperationClaim(User user, string operationClaimName)
 {
     using (var context = new YgykCarRentalProjectContext()) {
         var operationClaim = context.Set <OperationClaim>().SingleOrDefault(oc => oc.Name == operationClaimName);
         if (operationClaim != null)
         {
             // FIXME Duplicated code of EfEntityRepositoryBase.Add
             var entity = new UserOperationClaim {
                 UserId           = user.Id,
                 OperationClaimId = operationClaim.Id
             };
             var addedEntity = context.Entry(entity);
             addedEntity.State = EntityState.Added;
             context.SaveChanges();
         }
         // FIXME It will silently fail if the given operation claim doesn't exist, which is bad
     }
 }