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(); } }
internal FunctionalDefectStory CreateDefectStory(FunctionalDefectStory functionalDefectStory) { try { int maxDefectId = 1; if (context.FunctionalDefectStory.ToList().Count > 0) { maxDefectId = context.FunctionalDefectStory.Max(m => m.FunctionalDefectStory_Id); } maxDefectId = (context.FunctionalDefectStory.ToList().Count > 0) ? (maxDefectId + 1) : maxDefectId; functionalDefectStory.FunDefectStryCode = "RT" + maxDefectId + "FUNSTRDEFCODE" + (maxDefectId + 1); context.FunctionalDefectStory.Add(functionalDefectStory); context.SaveChanges(); return(functionalDefectStory); } catch (Exception ex) { functionalDefectStory.ErrorMessage = ex.Message; return(functionalDefectStory); } }
public static FunctionalDefectStory CreateDefectStory(FunctionalDefectStory functionalDefectStory) { dFunctionalDefect _dFunctionalDefect = new dFunctionalDefect(); return(_dFunctionalDefect.CreateDefectStory(functionalDefectStory)); }