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