Esempio n. 1
0
 private void Fetch(ProjectTracker.Dal.RoleDto data)
 {
     using (BypassPropertyChecks)
     {
         Id        = data.Id;
         Name      = data.Name;
         TimeStamp = data.LastChanged;
     }
 }
Esempio 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();
 }
Esempio 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;
     }
 }
Esempio 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;
   }
 }
Esempio 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;
     }
 }
Esempio 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;
      }
    }
Esempio 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);
 }