コード例 #1
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         var         db      = new Pizza15Model();
         tblContactU Contact = db.tblContactUs.FirstOrDefault(x => x.ID.Equals(1));
         if (Contact != null)
         {
             Contact.Call      = txtCall.Text;
             Contact.FindLine1 = txtFind1.Text;
             Contact.FindLine2 = txtFind2.Text;
             Contact.FindLine3 = txtFind3.Text;
             Contact.FindLine4 = txtFind4.Text;
             //Contact.FindLine5 = txtFind5.Text;
             Contact.HoursLine1 = txtHours1.Text;
             Contact.HoursLine2 = txtHours2.Text;
             Contact.HoursLine3 = txtHours3.Text;
             //Contact.HoursLine4 = txtHours4.Text;
             Contact.Email = txtEmail.Text;
             lblError.Text = "Update Succes";
             // Change 1 07/04/2020
             db.SaveChanges();
         }
     }
     catch
     {
         lblError.Text = "Internal server error";
     }
 }
コード例 #2
0
        public void Post([FromBody] tblContactU contactU)
        {
            try
            {
                tblContactU c = new tblContactU();
                c.ContactName     = contactU.ContactName;
                c.Email           = contactU.Email;
                c.RequestType     = contactU.RequestType;
                c.message         = contactU.message;
                c.status          = "Not Seen";
                c.ApprovalAdminId = null;

                db.tblContactUs.Add(c);
                db.SaveChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
コード例 #3
0
 public int SaveMessage(ContactUsModel model)
 {
     try
     {
         StratasFairDBEntities _context  = new StratasFairDBEntities();
         tblContactU           contactUs = new tblContactU();
         contactUs.CreatedOn     = DateTime.UtcNow;
         contactUs.CreatedFromIP = System.Web.HttpContext.Current.Request.UserHostAddress;
         contactUs.FirstName     = model.FirstName;
         contactUs.EmailAddress  = model.Email;
         contactUs.Message       = model.Message;
         contactUs.Status        = 1;
         _context.tblContactUs.Add(contactUs);
         if (_context.SaveChanges() > 0)
         {
             EmailSender.FncSend_ContactUsMail_ToAdmin(model.FirstName, model.Email, model.Message);
         }
         return(1);
     }
     catch
     {
         return(-1);
     }
 }