Ejemplo n.º 1
0
 public void Create(DalRole dalEntity)
 {
     if (dalEntity == null)
     {
         throw new ArgumentNullException("dalEntity", "Role is null");
     }
     _context.Set<Roles>().Add(new Roles()
     {
         RoleId = dalEntity.Id,
         Name = dalEntity.Name
     });
 }
Ejemplo n.º 2
0
 public void Delete(DalRole dalEntity)
 {
     if (dalEntity == null)
     {
         throw new ArgumentNullException("dalEntity", "Role is null");
     }
     var entity = new Roles()
     {
         RoleId = dalEntity.Id,
         Name = dalEntity.Name
     };
     _context.Set<Roles>().Remove(entity);
 }
Ejemplo n.º 3
0
 public void Update(DalRole dalEntity)
 {
     if (dalEntity == null)
     {
         throw new ArgumentNullException("dalEntity", "Role is null");
     }
     var oldEntity = _context.Set<Roles>().Find(dalEntity.Id);
     if (oldEntity != null)
     {
         var oldContextEntry = _context.Entry(oldEntity);
         var newEntity = new Roles()
         {
             RoleId = dalEntity.Id,
             Name = dalEntity.Name
         };
         oldContextEntry.CurrentValues.SetValues(newEntity);
         oldContextEntry.State = EntityState.Modified;
     }
 }