Beispiel #1
0
 private void Fetch(ProjectTracker.Dal.AssignmentDto data, [Inject] IProjectDal dal)
 {
     using (BypassPropertyChecks)
     {
         ProjectId = data.ProjectId;
         Role      = data.RoleId;
         LoadProperty(AssignedProperty, data.Assigned);
         TimeStamp = data.LastChanged;
         var project = dal.Fetch(data.ProjectId);
         ProjectName = project.Name;
     }
 }
Beispiel #2
0
 public void Insert(AssignmentDto item)
 {
   item.LastChanged = MockDb.GetTimeStamp();
   var newItem = new AssignmentData
   {
     ProjectId = item.ProjectId,
     ResourceId = item.ResourceId,
     Assigned = item.Assigned,
     RoleId = item.RoleId,
     LastChanged = item.LastChanged
   };
   MockDb.Assignments.Add(newItem);
 }
Beispiel #3
0
 private void Fetch(ProjectTracker.Dal.AssignmentDto data, [Inject] IResourceDal dal)
 {
     using (BypassPropertyChecks)
     {
         ResourceId = data.ResourceId;
         Role       = data.RoleId;
         LoadProperty(AssignedProperty, data.Assigned);
         TimeStamp = data.LastChanged;
         var person = dal.Fetch(data.ResourceId);
         FirstName = person.FirstName;
         LastName  = person.LastName;
     }
 }
Beispiel #4
0
 public void Update(AssignmentDto item)
 {
   var data = (from r in MockDb.Assignments
                  where r.ProjectId == item.ProjectId && r.ResourceId == item.ResourceId
                  select r).FirstOrDefault();
   if (data == null)
     throw new DataNotFoundException("Assignment");
   if (!data.LastChanged.Matches(item.LastChanged))
     throw new ConcurrencyException("Assignment");
   item.LastChanged = MockDb.GetTimeStamp();
   data.Assigned = item.Assigned;
   data.RoleId = item.RoleId;
   data.LastChanged = item.LastChanged;
 }
Beispiel #5
0
 private void Insert(int projectId, [Inject] IAssignmentDal dal)
 {
     using (BypassPropertyChecks)
     {
         var item = new ProjectTracker.Dal.AssignmentDto
         {
             ProjectId  = projectId,
             ResourceId = this.ResourceId,
             Assigned   = ReadProperty(AssignedProperty),
             RoleId     = this.Role
         };
         dal.Insert(item);
         TimeStamp = item.LastChanged;
     }
 }
Beispiel #6
0
 public void Insert(AssignmentDto item)
 {
   using (var ctx = ObjectContextManager<PTrackerEntities>.GetManager("PTrackerEntities"))
   {
     var newItem = new Assignment
     {
       ProjectId = item.ProjectId,
       ResourceId = item.ResourceId,
       Assigned = item.Assigned,
       RoleId = item.RoleId
     };
     ctx.ObjectContext.AddToAssignments(newItem);
     ctx.ObjectContext.SaveChanges();
     item.LastChanged = newItem.LastChanged;
   }
 }
Beispiel #7
0
 public void Update(AssignmentDto item)
 {
   using (var ctx = ObjectContextManager<PTrackerEntities>.GetManager("PTrackerEntities"))
   {
     var data = (from r in ctx.ObjectContext.Assignments
                 where r.ProjectId == item.ProjectId && r.ResourceId == item.ResourceId
                 select r).FirstOrDefault();
     if (data == null)
       throw new DataNotFoundException("Assignment");
     if (!data.LastChanged.Matches(item.LastChanged))
       throw new ConcurrencyException("Assignment");
     data.Assigned = item.Assigned;
     data.RoleId = item.RoleId;
     var count = ctx.ObjectContext.SaveChanges();
     if (count == 0)
       throw new UpdateFailureException("Assignment");
     item.LastChanged = data.LastChanged;
   }
 }