Exemplo n.º 1
0
 private void Fetch(ProjectTracker.Dal.RoleDto data)
 {
     using (BypassPropertyChecks)
     {
         Id        = data.Id;
         Name      = data.Name;
         TimeStamp = data.LastChanged;
     }
 }
Exemplo n.º 2
0
 public void Update(RoleDto item)
 {
   var data = (from r in MockDb.Roles
              where r.Id == item.Id
              select r).FirstOrDefault();
   if (data == null)
     throw new DataNotFoundException("Role");
   data.Name = item.Name;
   data.LastChanged = MockDb.GetTimeStamp();
 }
Exemplo n.º 3
0
 private void Insert([Inject] IRoleDal dal)
 {
     using (BypassPropertyChecks)
     {
         var item = new ProjectTracker.Dal.RoleDto
         {
             Name = this.Name
         };
         dal.Insert(item);
         Id        = item.Id;
         TimeStamp = item.LastChanged;
     }
 }
Exemplo n.º 4
0
 public void Insert(RoleDto item)
 {
   using (var ctx = ObjectContextManager<PTrackerEntities>.GetManager("PTrackerEntities"))
   {
     var newItem = new Role 
     { 
       Name = item.Name
     };
     ctx.ObjectContext.AddToRoles(newItem);
     ctx.ObjectContext.SaveChanges();
     item.Id = newItem.Id;
     item.LastChanged = newItem.LastChanged;
   }
 }
Exemplo n.º 5
0
 private void Update([Inject] IRoleDal dal)
 {
     using (BypassPropertyChecks)
     {
         var item = new ProjectTracker.Dal.RoleDto
         {
             Id          = this.Id,
             Name        = this.Name,
             LastChanged = this.TimeStamp
         };
         dal.Update(item);
         Id        = item.Id;
         TimeStamp = item.LastChanged;
     }
 }
Exemplo n.º 6
0
    public void Update(RoleDto item)
    {
      using (var ctx = ObjectContextManager<PTrackerEntities>.GetManager("PTrackerEntities"))
      {
        var data = (from r in ctx.ObjectContext.Roles
                    where r.Id == item.Id
                    select r).FirstOrDefault();
        if (data == null)
          throw new DataNotFoundException("Role");
        if (!data.LastChanged.Matches(item.LastChanged))
          throw new ConcurrencyException("Role");

        data.Name = item.Name;
        var count = ctx.ObjectContext.SaveChanges();
        if (count == 0)
          throw new UpdateFailureException("Role");
        item.LastChanged = data.LastChanged;
      }
    }
Exemplo n.º 7
0
 public void Insert(RoleDto item)
 {
   item.Id = MockDb.Roles.Max(c => c.Id) + 1;
   var newItem = new RoleData { Id = item.Id, Name = item.Name, LastChanged = MockDb.GetTimeStamp() };
   MockDb.Roles.Add(newItem);
 }