コード例 #1
0
    protected void btnCheckIn_Click(object sender, EventArgs e)
    {
        using (CrackerEntities myEntity = new CrackerEntities())
        {
            ITransactionRepository transactionRepo = new TransactionRepository();
            IBugRepository bugRepo = new BugRepository();

            string bugName = Request.QueryString.Get("BugID");

            var bugId = bugRepo.GetBugIdByTitle(bugName);

            Transaction myTransaction = new Transaction
            {
                BugId = (int)bugId,
                ChangedBy = HttpContext.Current.User.Identity.Name,
                ChangedOn = DateTime.Now,
                StatusId = Int32.Parse(((DropDownList)LoginView1.FindControl("ddlResolution")).SelectedValue),
                TimeSpent = Int32.Parse(((TextBox)LoginView1.FindControl("txtTime")).Text),
                LanguageId = Int32.Parse(((DropDownList)LoginView1.FindControl("ddlLanguages")).SelectedValue),
                Note = HttpUtility.HtmlEncode(((TextBox)LoginView1.FindControl("txtNote")).Text)
            };

            transactionRepo.InsertTransaction(myTransaction);
            transactionRepo.Save();

        }
        Response.Redirect("~/Default.aspx");
    }
コード例 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string bugName = Request.QueryString.Get("BugID");

        string checkedOutBy;
        DateTime changedOn;

        using (CrackerEntities myEntity = new CrackerEntities())
        {
            ITransactionRepository transactionRepo = new TransactionRepository();

            //Verify that the bug we are going to check in can be checked in
            //Get bug ID
            var result = (from bug in myEntity.Bugs
                        where bug.Bug1 == bugName
                        select bug).SingleOrDefault();

            if (result != null)
            {
                var check = transactionRepo.GetLastTransactionForBug(result.Id);

                changedOn = Convert.ToDateTime(check.ChangedOn);
                checkedOutBy = Convert.ToString(check.ChangedBy);

                if (checkedOutBy !=  HttpContext.Current.User.Identity.Name)
                {
                    ((Label)LoginView1.FindControl("lblWarning")).ForeColor = System.Drawing.Color.Red;
                    ((Label)LoginView1.FindControl("lblWarning")).Text = "You're about to check in a bug that was not checked out by you!";
                }

                //get how long has the bug been checked out
                ((TextBox)LoginView1.FindControl("txtTime")).Text = Math.Round(DateTime.Now.Subtract(changedOn).TotalMinutes, 0).ToString();

                ((Label)LoginView1.FindControl("lblBugId")).Text = bugName;
            }
            else
            {
                ((Label)LoginView1.FindControl("lblBugId")).ForeColor = System.Drawing.Color.Red;
                ((Label)LoginView1.FindControl("lblBugId")).Text = bugName + " does not exist!";
                ((Button)LoginView1.FindControl("btnCheckIn")).Enabled = false;

            }

        }
    }
コード例 #3
0
 public TransactionRepository()
 {
     this._context = new CrackerEntities();
 }
コード例 #4
0
 public BugRepository()
 {
     this._context = new CrackerEntities();
 }