public static List <ProjectInfo> getUserProjects(string Username, bool OnlyActive) { if (!User.UsernameExists(Username)) { throw new ArgumentException("Username doesn't exist"); } ProjectTableAdapter projectAdapter = new ProjectTableAdapter(); NuRacingDataSet.ProjectDataTable projectTable = projectAdapter.GetData(); List <ProjectInfo> result = new List <ProjectInfo>(); foreach (NuRacingDataSet.ProjectRow projectRow in projectTable.Rows) { if (!( (OnlyActive && (!projectRow.Project_Active)) || !(Project.userInvolvedIn(Username, projectRow.Project_UID)))) { result.Add(new ProjectInfo(projectRow)); } } return(result); }
public static void CompleteTask(string[] Usernames, DateTime DateCompleted, int AssignedTaskID, string Description, int TimeWorkedMins, TakeFiveResponse[] takeFiveResponses) { foreach (string Username in Usernames) { if (!User.UsernameExists(Username)) { throw new ArgumentException("Username doesn't exist"); } if ((new AssignedUserTableAdapter()).GetDataByBoth(AssignedTaskID, Username).Rows.Count == 0) { throw new ArgumentException("Username wasn't consistant with Assigned Task record"); } } if (AssignedTask.taskExists(AssignedTaskID)) { throw new ArgumentException("Task doesn't exist"); } int WorkTypeID = ((NuRacingDataSet.AssignedTaskRow)((new AssignedTaskTableAdapter()).GetAssignedTask(AssignedTaskID).Rows[0])).WorkType_UID; StoreWork(DateCompleted, Description, AssignedTaskID, WorkTypeID, TimeWorkedMins, true); int WorkID = findWorkID(DateCompleted, Description, AssignedTaskID, WorkTypeID, TimeWorkedMins, true); StoreWorkDoneBy(Usernames, WorkID); StoreTakeFivesTaken(takeFiveResponses, WorkID); }
public static void AddSponsor(string Username, int ProjectID) { if (!User.UsernameExists(Username)) { throw new ArgumentException("Username wasn't valid"); } if (Role.GetUserRole(Username) != "Sponsor") { throw new ArgumentException("User isn't a sponsor"); } if (!Project.projectExists(ProjectID)) { throw new ArgumentException("ProjectID wasn't valid"); } SponsoredTableAdapter sponsoredAdapter = new SponsoredTableAdapter(); NuRacingDataSet.SponsoredDataTable sponsoredTable = sponsoredAdapter.GetDataByBoth(Username, ProjectID); if (sponsoredTable.Rows.Count != 0) { throw new ArgumentException("User is already sponsoring that project"); } NuRacingDataSet.SponsoredRow sponsoredRow = sponsoredTable.NewSponsoredRow(); sponsoredRow.User_UserName = Username; sponsoredRow.Project_UID = ProjectID; sponsoredTable.AddSponsoredRow(sponsoredRow); sponsoredAdapter.Update(sponsoredTable); }
//Written By Simon Davis /// <summary> /// Returns a UserInfo object for the specified user /// </summary> /// <param name="Username">User's username</param> /// <returns></returns> static public UserInfo getUser(string Username) { if (!User.UsernameExists(Username)) { throw new ArgumentException("Username wasn't valid"); } UserTableAdapter userAdapter = new UserTableAdapter(); NuRacingDataSet.UserDataTable userTable = userAdapter.GetUser(Username); NuRacingDataSet.UserRow userRow = (NuRacingDataSet.UserRow)userTable.Rows[0]; UserInfo userInfo = new UserInfo(userRow); return(userInfo); }
public static void AddWork(string[] Usernames, DateTime DateCompleted, string Description, int WorkTypeID, int TimeWorkedMins, bool TakeFiveTaken) { foreach (String Username in Usernames) { if (!User.UsernameExists(Username)) { throw new ArgumentException("Username doesn't exist: " + Username); } } if (WorkType.WorkTypeExists(WorkTypeID)) { throw new ArgumentException("Work Type doesn't exist"); } StoreWork(DateCompleted, Description, null, WorkTypeID, TimeWorkedMins, TakeFiveTaken); int WorkID = findWorkID(DateCompleted, Description, null, WorkTypeID, TimeWorkedMins, TakeFiveTaken); StoreWorkDoneBy(Usernames, WorkID); }
public static void RemoveSponsor(string Username, int ProjectID) { if (!User.UsernameExists(Username)) { throw new ArgumentException("Username wasn't valid"); } if (!Project.projectExists(ProjectID)) { throw new ArgumentException("ProjectID wasn't valid"); } SponsoredTableAdapter sponsoredAdapter = new SponsoredTableAdapter(); NuRacingDataSet.SponsoredDataTable sponsoredTable = sponsoredAdapter.GetDataByBoth(Username, ProjectID); foreach (NuRacingDataSet.SponsoredRow row in sponsoredTable.Rows) { row.Delete(); } sponsoredAdapter.Update(sponsoredTable); }