Example #1
0
        public ActionResult Create([Bind(Include = "SectionName,SectionDescription,Visible,Created,Modified,CreatedBy,ModifiedBy,NewsLetterID")] Section section)
        {
            if (ModelState.IsValid)
            {
                section.Created    = DateTime.Now;
                section.CreatedBy  = User.Identity.Name;
                section.Modified   = DateTime.Now;
                section.ModifiedBy = User.Identity.Name;
                db.Sections.Add(section);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.NewsLetterID = new SelectList(db.NewsLetters, "NewsLetterID", "Name", section.NewsLetterID);
            return(View(section));
        }
Example #2
0
        public ActionResult Create([Bind(Include = "NewsItemName,NewsItemDescription,ActualLink,Visible,Created,Modified,CreatedBy,ModifiedBy,SectionID")] NewsItem newsItem)
        {
            if (ModelState.IsValid)
            {
                newsItem.Created    = DateTime.Now;
                newsItem.CreatedBy  = User.Identity.Name;
                newsItem.Modified   = DateTime.Now;
                newsItem.ModifiedBy = User.Identity.Name;
                db.NewsItems.Add(newsItem);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.SectionID = new SelectList(db.Sections, "SectionID", "SectionName", newsItem.SectionID);
            return(View(newsItem));
        }
        public ActionResult Create([Bind(Include = "NewsLetterID,Name,Description,Visible,Created,Modified,CreatedBy,ModifiedBy,TenantID")] NewsLetter newsLetter)
        {
            if (ModelState.IsValid)
            {
                newsLetter.CreatedBy  = User.Identity.Name;
                newsLetter.ModifiedBy = User.Identity.Name;
                newsLetter.Created    = DateTime.Now;
                newsLetter.Modified   = DateTime.Now;

                db.NewsLetters.Add(newsLetter);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.TenantID = new SelectList(db.Tenants, "TenantID", "TenantName", newsLetter.TenantID);
            return(View(newsLetter));
        }
 public ActionResult Unsubscribe(int Id)
 {
     using (NewsLetterEntities db = new NewsLetterEntities())
     {
         var signup = db.SignUps.Find(Id);
         signup.Removed = DateTime.Now;
         db.SaveChanges();
     }
     return RedirectToAction("Index");
 }
Example #5
0
 // GET: Tenants/Create
 public ActionResult Create()
 {
     DatabaseContext.Tenant tenant = new Tenant();
     if (true)
     {
         Models.Tenant tenantModel = ClaimsIdentityExtensions.GetTenant();
         tenant.TenantID     = tenantModel.TenantID;
         tenant.TenantName   = tenantModel.TenantName;
         tenant.ClientID     = Startup.clientId;
         tenant.ClientSecret = new Startup().appKey;
         tenant.URL          = tenantModel.TenantDomain;
         tenant.Modified     = DateTime.Now.Date;
         tenant.Created      = DateTime.Now.Date;
         tenant.CreateBy     = User.Identity.Name;
         tenant.ModifiedBy   = User.Identity.Name;
         db.Tenants.Add(tenant);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
        public ActionResult SignUp(string firstName, string lastName, string emailAddress)
        {
            if (string.IsNullOrEmpty(firstName) || string.IsNullOrEmpty(lastName) || string.IsNullOrEmpty(emailAddress))
            {
                return(View("~/Views/Shared/Error.cshtml"));
            }
            else
            {
                using (NewsLetterEntities db = new NewsLetterEntities())
                {
                    var signup = new SignUp();
                    signup.FirstName    = firstName;
                    signup.LastName     = lastName;
                    signup.EmailAddress = emailAddress;

                    db.SignUps.Add(signup);
                    db.SaveChanges();
                }

                //string queryString = @"INSERT INTO SignUps (FirstName, LastName, EmailAddress) VALUES
                //            (@FirstName, @LastName, @EmailAddress)";

                //using (SqlConnection connection = new SqlConnection(connectionString))
                //{
                //    SqlCommand command = new SqlCommand(queryString, connection);
                //    command.Parameters.Add("@FirstName", SqlDbType.VarChar);
                //    command.Parameters.Add("@LastName", SqlDbType.VarChar);
                //    command.Parameters.Add("@EmailAddress", SqlDbType.VarChar);

                //    command.Parameters["@FirstName"].Value = firstName;
                //    command.Parameters["@LastName"].Value = lastName;
                //    command.Parameters["@EmailAddress"].Value = emailAddress;

                //    connection.Open();
                //    command.ExecuteNonQuery();
                //    connection.Close();

                //}
                return(View("Success"));
            }
        }
        public ActionResult SignUp(string firstName, string lastName, string emailAddress)
        {
            if (string.IsNullOrEmpty(firstName) || string.IsNullOrEmpty(lastName) || string.IsNullOrEmpty(emailAddress))
            {
                return(View("~/Views/Shared/Errors.cshtml"));
            }
            else
            {
                using (NewsLetterEntities db = new NewsLetterEntities())
                {
                    var signup = new SignUp();
                    signup.FirstName    = firstName;
                    signup.LastName     = lastName;
                    signup.EmailAddress = emailAddress;

                    db.SignUps.Add(signup);
                    db.SaveChanges();
                }
                return(View("Success"));
            }
        }