Exemple #1
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            int adminId = Convert.ToInt32(Session[ConfigurationSettings.AppSettings["SupportSession"].ToString()].ToString());
            FunctionalDefect functionalDefect = new FunctionalDefect()
            {
                Title             = txtFullname.Text,
                Description       = txtDescription.Text,
                FixDate           = Convert.ToDateTime(txtDueDate.Text),
                Administrators_Id = adminId,
                Status            = ddlStatus.Text,
                Resolver_Id       = Convert.ToInt32(ddlResolver.SelectedValue),
                CreatedDate       = DateTime.Now,
                UpdatedDate       = DateTime.Now,
                Priority          = rdoPriority.Text
            };

            functionalDefect = bFunctionalDefect.Create(functionalDefect);
            if (string.IsNullOrEmpty(functionalDefect.ErrorMessage))
            {
                FunctionalDefectStory functionalDefectStory = new FunctionalDefectStory()
                {
                    Defect_Id         = functionalDefect.Defect_Id,
                    Title             = txtFullname.Text,
                    Description       = txtDescription.Text,
                    FixDate           = Convert.ToDateTime(txtDueDate.Text),
                    Administrators_Id = adminId,
                    Status            = ddlStatus.Text,
                    Resolver_Id       = Convert.ToInt32(ddlResolver.SelectedValue),
                    CreatedDate       = DateTime.Now,
                    UpdatedDate       = DateTime.Now,
                    Priority          = rdoPriority.Text
                };

                functionalDefectStory = bFunctionalDefect.CreateDefectStory(functionalDefectStory);

                if (Convert.ToBoolean(ConfigurationSettings.AppSettings["IsEmailEnable"]))
                {
                    string mailBody      = MailHelper.DefectAddedOrUpdated(functionalDefect);
                    string emailIdToSend = MailHelper.EmailToSend();

                    string CreatorAdmin   = bAdministrator.List().Where(m => m.Administrators_Id == functionalDefect.Administrators_Id).FirstOrDefault().EmailId;
                    string DeveloperAdmin = bAdministrator.List().Where(m => m.Administrators_Id == functionalDefect.Resolver_Id).FirstOrDefault().EmailId;
                    emailIdToSend = emailIdToSend + ";" + CreatorAdmin;
                    emailIdToSend = emailIdToSend + ";" + DeveloperAdmin;
                    MailHelper.SendEmail(emailIdToSend, "New Ticket Created", mailBody, "Support Team");
                }
                pnlErrorMessage.Attributes.Remove("class");
                pnlErrorMessage.Attributes["class"] = "alert alert-success alert-dismissable";
                pnlErrorMessage.Visible             = true;
                lblMessage.Text = "Success! New Ticket created successfully";
            }
            else
            {
                pnlErrorMessage.Attributes.Remove("class");
                pnlErrorMessage.Attributes["class"] = "alert alert-danger alert-dismissable";
                pnlErrorMessage.Visible             = true;
                lblMessage.Text = "Faied! to create the ticket. Error : " + Request.QueryString["errormessage"].ToString();
            }
        }