/// <summary> /// btnSubmit_Click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSubmit_Click(object sender, EventArgs e) { var success = false; try { if (!String.IsNullOrEmpty(txtSubject.Text) && !String.IsNullOrEmpty(txtDescription.Text)) { var issue = new Issue(); issue.Subject = txtSubject.Text; issue.ProjectID = Int32.Parse(ddlProjects.SelectedValue); issue.CurrentPriority = (Issue.IssuePriority)Enum.Parse(typeof(Issue.IssuePriority), ddlIssuePriority.SelectedValue); issue.CurrentStatus = (Issue.IssueStatus)Enum.Parse(typeof(Issue.IssueStatus), ddlIssueStatus.SelectedValue); issue.Description = txtDescription.Text; issue.Milestone = 0; //TODO: check where this value comes from. issue.EntryDate = DateTime.Parse(txtEntryDate.Text); issue.IssueCategoryName = txtCategory.Text; // assignee var user = new User(); user.UserId = Int32.Parse(ddlAssignee.SelectedItem.Value); issue.Assignee = user; // add new issue. success = IssueBLL.AddIssue(issue); if (success) Response.Redirect("~/Issues.aspx"); } } catch (Exception) { throw; } }
/// <summary> /// GetUserGivenLogonName /// </summary> /// <param name="logonName"></param> /// <returns></returns> public static User GetUserGivenLogonName(string logonName) { var user = new User(); try { using (var db = new ProjectManagerEntities()) { var query = (from u in db.UserDALs where u.UserName == logonName select u).First(); if (query != null) { user.UserId = query.UserID; user.UserName = query.UserName; user.Password = query.Password; user.UserRole = query.UserRole; user.FirstName = query.FirstName; user.LastName = query.LastName; user.Email = query.Email; user.PhoneNumber = query.PhoneNumber; user.Position = query.Position; user.TeamName = query.Position; } } } catch (Exception) { throw; } return user; }
public void RequiredPasswordFieldTest() { var user = new User() { UserName = "******", Password = "" }; var context = new ValidationContext(user, serviceProvider: null, items: null); var results = new List<ValidationResult>(); var isValid = Validator.TryValidateObject(user, context, results); var sb = new StringBuilder(); if (!isValid) { foreach (var validationResult in results) { // add validation error message to string builder. sb.Append(validationResult.ErrorMessage); } } // check if "The Password field is required." is in the error message. Assert.IsTrue(sb.ToString().Contains("The Password field is required.")); }
/// <summary> /// GetUserInfo /// </summary> /// <param name="userName"></param> /// <returns>User Object</returns> public User GetUserInfo(string userName) { User user = new User(); using (SqlConnection sqlConnection = new SqlConnection(Constants.DATABASE.CONNECTION_STRING)) { sqlConnection.Open(); using (SqlCommand sqlCommand = new SqlCommand("SELECT * FROM USERS WHERE UserName='******'", sqlConnection)) { using (SqlDataReader sqlDataReader = sqlCommand.ExecuteReader()) { if (sqlDataReader.HasRows) { while (sqlDataReader.Read()) { user.UserId = Convert.ToInt32(sqlDataReader["UserID"]); user.UserName = Convert.ToString(sqlDataReader["UserName"]); user.UserRole = Convert.ToString(sqlDataReader["UserRole"]); user.FirstName = Convert.ToString(sqlDataReader["FirstName"]); user.LastName = Convert.ToString(sqlDataReader["UserID"]); user.Email = Convert.ToString(sqlDataReader["Email"]); user.PhoneNumber = Convert.ToString(sqlDataReader["PhoneNumber"]); user.Position = Convert.ToString(sqlDataReader["Position"]); user.TeamName = Convert.ToString(sqlDataReader["TeamName"]); } } sqlDataReader.Close(); } } sqlConnection.Close(); } return user; }
/// <summary> /// GetIssueList /// </summary> /// <returns></returns> public List<Issue> GetIssueList(int projectID) { List<Issue> issues = new List<Issue>(); try { using (var db = new ProjectManagerEntities()) { // get the list of issues for a specific ProjectID. var query = (from i in db.IssueDALs join ia in db.IssueAssignmentDALs on i.IssueID equals ia.IssueID into IandIA from iaJoin in IandIA.DefaultIfEmpty() join u in db.UserDALs on iaJoin.UserID equals u.UserID into IAandU from uJoin in IAandU.DefaultIfEmpty() where i.ProjectID == projectID select new { IssueID = iaJoin.IssueID, Subject = i.Subject, Priority = i.Priority, Status = i.Status, ProjectID = i.ProjectID, UserID = uJoin.UserID, Username = uJoin.UserName, Password = uJoin.Password, UserRole = uJoin.UserRole, FirstName = uJoin.FirstName, LastName = uJoin.LastName, Email = uJoin.Email, PhoneNumber = uJoin.PhoneNumber, Position = uJoin.Position, TeamName = uJoin.TeamName, IssueCategoryName = i.IssueCategoryName, EntryDate = i.EntryDate, Description = i.Description }); foreach (var item in query) { // build the issue object. var myissue = new Issue() { IssueID = item.IssueID, Subject = item.Subject, CurrentStatus = (Issue.IssueStatus)Enum.Parse(typeof(Issue.IssueStatus), item.Status), CurrentPriority = (Issue.IssuePriority)Enum.Parse(typeof(Issue.IssuePriority), item.Priority), ProjectID = item.ProjectID, IssueCategoryName = item.IssueCategoryName, EntryDate = item.EntryDate ?? DateTime.MinValue, Description = item.Description }; // Get the Issue Assignee var user = new User(item.UserID, item.Username, item.Password, item.UserRole, item.FirstName, item.LastName, item.Email, item.PhoneNumber, item.Position, item.TeamName); user.FirstName = item.FirstName; user.LastName = item.LastName; myissue.Assignee = user; issues.Add(myissue); } } } catch (Exception) { throw; } return issues; }
/// <summary> /// Get Issue /// </summary> /// <param name="issueID">int</param> /// <returns>Issue</returns> public static Issue GetIssue(int issueID) { var issue = new Issue(); try { // get issue information from database. using (var db = new ProjectManagerEntities()) { var query = (from i in db.IssueDALs join ia in db.IssueAssignmentDALs on i.IssueID equals ia.IssueID into IandIA from iaJoin in IandIA.DefaultIfEmpty() join u in db.UserDALs on iaJoin.UserID equals u.UserID into IAandU from uJoin in IAandU.DefaultIfEmpty() where i.IssueID == issueID select new { IssueID = iaJoin.IssueID, Subject = i.Subject, Priority = i.Priority, Status = i.Status, ProjectID = i.ProjectID, UserID = uJoin.UserID, Username = uJoin.UserName, Password = uJoin.Password, UserRole = uJoin.UserRole, FirstName = uJoin.FirstName, LastName = uJoin.LastName, Email = uJoin.Email, PhoneNumber = uJoin.PhoneNumber, Position = uJoin.Position, TeamName = uJoin.TeamName, IssueCategoryName = i.IssueCategoryName, EntryDate = i.EntryDate, Description = i.Description }).FirstOrDefault(); if (query != null) { // build the issue object. issue = new Issue() { IssueID = query.IssueID, Subject = query.Subject, CurrentStatus = (Issue.IssueStatus)Enum.Parse(typeof(Issue.IssueStatus), query.Status), CurrentPriority = (Issue.IssuePriority)Enum.Parse(typeof(Issue.IssuePriority), query.Priority), ProjectID = query.ProjectID, IssueCategoryName = query.IssueCategoryName, EntryDate = query.EntryDate ?? DateTime.MinValue, Description = query.Description }; // Get the Issue Assignee var user = new User(query.UserID, query.Username, query.Password, query.UserRole, query.FirstName, query.LastName, query.Email, query.PhoneNumber, query.Position, query.TeamName); user.FirstName = query.FirstName; user.LastName = query.LastName; issue.Assignee = user; } } } catch (Exception) { throw; } return issue; }
private Project CreateThirdTestProject() { Project project = CreateSecondTestProject(); User user = new User(0, "AUser", "", "", "", "", "", "", "", ""); Issue issue = new Issue(); issue.Assignee = user; project.AddIssue(issue); return project; }
private Project CreateSecondTestProject() { Project project = CreateInitialProject(); User user2 = new User(0, "User2", "", "", "", "", "", "", "", ""); Issue issue = new Issue(); issue.Assignee = user2; project.AddIssue(issue); issue = new Issue(); issue.Assignee = user2; project.AddIssue(issue); return project; }