public void UpdateAssignment(ExecutionContextInfo context, Assignment assignment) { if (assignment == null) { throw new ArgumentNullException("assignment"); } if (assignment.Identifier == Guid.Empty) { throw new ArgumentNullException("Assignment.Identifier"); } using (var ctx = new Server.System.Repository.DataAccess.CaseHandlingDatabaseContext()) { var assignmentEntity = (from c in ctx.AssignmentEntities where c.ID == assignment.Identifier select c).FirstOrDefault(); if (assignmentEntity == null) { throw new CaseHandlingException(string.Format("Assignment ({0}) information not found provided by Workflow ({1})", assignment.Identifier, assignment.FlowInstanceIdentifier)); } var ca = assignmentEntity; ca.Accepted = assignment.Accepted; ca.Assigned = assignment.Assigned; ca.Active = assignment.Active; ca.FlowInstanceID = assignment.FlowInstanceIdentifier; ctx.SaveChanges(); } }
public Assignment CreateAssignment(ExecutionContextInfo context, Assignment assignment) { if (assignment == null) { throw new ArgumentNullException("assignment"); } if (assignment.Case == null || assignment.Case.Identifier == Guid.Empty) { throw new ArgumentNullException("Assignment.Case.Identifier"); } if (assignment.Officer == null || assignment.Officer.Identifier == Guid.Empty) { throw new ArgumentNullException("Assignment.Officer.Identifier"); } if (assignment.Assigned == null) { assignment.Assigned = DateTime.Now; } using (var ctx = new Server.System.Repository.DataAccess.CaseHandlingDatabaseContext()) { var caseEntity = (from ca in ctx.CaseEntities where ca.ID == assignment.Case.Identifier select ca).FirstOrDefault(); var officerEntity = (from of in ctx.OfficerEntities where of.ID == assignment.Officer.Identifier select of).FirstOrDefault(); if (caseEntity == null || officerEntity == null) { throw new CaseHandlingException(string.Format("Case ({0}) or Officer ({1}) information not found provided by Workflow ({2})", assignment.Case.Identifier, assignment.Officer.Identifier, assignment.FlowInstanceIdentifier)); } var c = new AssignmentEntity() { ID = Guid.NewGuid(), Case = caseEntity, Officer = officerEntity, Active = true, Assigned = assignment.Assigned, FlowInstanceID = assignment.FlowInstanceIdentifier, }; ctx.AssignmentEntities.AddObject(c); ctx.SaveChanges(); assignment.Active = c.Active; assignment.Identifier = c.ID; return(assignment); } }