public static Workflow Update(Workflow workflow) { Workflow wf = WorkflowMapper.Instance.Update(workflow); if (wf.IsWorkflowUserListLoaded) { WorkflowUserMapper.Instance.DeleteWorkflowUsers(wf.WorkflowId.GetValueOrDefault()); foreach (WorkflowUser wfu in wf.WorkflowUserList) { wfu.WorkflowId = wf.WorkflowId.GetValueOrDefault(); WorkflowUser.Update(wfu); } } return(wf); }
protected override object ReadRow(IRowReader reader) { WorkflowUser workflowUser = WorkflowUser.New(); // Table Fields workflowUser.WorkflowUserId = reader.GetInt32("WorkflowUserId"); workflowUser.WorkflowId = reader.GetInt32("WorkflowId"); workflowUser.UserId = reader.GetInt32("UserId"); workflowUser.Position = reader.GetInt32("Position"); workflowUser.DateAdded = reader.GetDateTime("DateAdded"); // View Fields workflowUser.UserFullName = reader.GetString("UserFullName"); workflowUser.IsDirty = false; workflowUser.ChangedProperties.Clear(); return(workflowUser); }
public virtual WorkflowUser Update(WorkflowUser workflowUser) { if (!workflowUser.IsDirty || workflowUser.IsNull) { // Nothing to do - no point hammering the database unnecessarily return(workflowUser); } IDbCommand command = CreateCommand(); if (workflowUser.IsNew) { // Adding command.CommandText = "INSERT INTO [WorkflowUser] ([WorkflowId], [UserId], [Position], [DateAdded]) VALUES (@workflowId, @userId, @position, @dateAdded) ; SELECT @@identity AS NewId;"; } else { // Updating command.CommandText = "UPDATE [WorkflowUser] SET [WorkflowId] = @workflowId, [UserId] = @userId, [Position] = @position, [DateAdded] = @dateAdded WHERE WorkflowUserId = @workflowUserId"; } command.Parameters.Add(CreateParameter("@workflowId", workflowUser.WorkflowId)); command.Parameters.Add(CreateParameter("@userId", workflowUser.UserId)); command.Parameters.Add(CreateParameter("@position", workflowUser.Position)); command.Parameters.Add(CreateParameter("@dateAdded", workflowUser.DateAdded)); if (workflowUser.IsNew) { workflowUser.WorkflowUserId = Convert.ToInt32(ExecScalar(command)); } else { command.Parameters.Add(CreateParameter("@workflowUserId", workflowUser.WorkflowUserId)); ExecuteCommand(command); } workflowUser.IsDirty = false; workflowUser.ChangedProperties.Clear(); return(workflowUser); }
public static WorkflowUser FindOne(WorkflowUserFinder finder) { WorkflowUser WorkflowUser = WorkflowUserMapper.Instance.FindOne(finder); return(WorkflowUser ?? Empty); }
public static WorkflowUser Update(WorkflowUser workflowUser) { return(WorkflowUserMapper.Instance.Update(workflowUser)); }
public static WorkflowUser Get(Nullable <Int32> WorkflowUserId) { WorkflowUser WorkflowUser = WorkflowUserMapper.Instance.Get(WorkflowUserId); return(WorkflowUser ?? Empty); }