コード例 #1
0
 public async Task AddNews()
 {
     var news = new NewsBusiness();
     var list = new List <ViewModels.News>
     {
         new ViewModels.News
         {
             Show        = true,
             Id          = Guid.NewGuid(),
             Approved    = true,
             Description = "Area 51 is working with Church on The Street (COTS). We have committed to assist one Sunday a month and will need 5 volunteers each month.",
             End         = new DateTime(2015, 12, 31),
             Link        = "http://www.signupgenius.com/go/9040b44a5ab23a57-church1?utm_source=Pax&utm_campaign=8c5dc78a00-Newsletter_9_6_2015&utm_medium=email&utm_term=0_e2070eb2f3-8c5dc78a00-53412961",
             Order       = 1,
             Start       = new DateTime(2015, 9, 6),
             Title       = "Church on the Street"
         },
         new ViewModels.News
         {
             Show        = true,
             Id          = Guid.NewGuid(),
             Approved    = true,
             Description = "Area 51 is working with Church on The Street (COTS). We have committed to assist one Sunday a month and will need 5 volunteers each month.",
             End         = new DateTime(2015, 12, 31),
             Link        = "http://www.signupgenius.com/go/9040b44a5ab23a57-church1?utm_source=Pax&utm_campaign=8c5dc78a00-Newsletter_9_6_2015&utm_medium=email&utm_term=0_e2070eb2f3-8c5dc78a00-53412961",
             Order       = 1,
             Start       = new DateTime(2015, 9, 6),
             Title       = "Church on the Street"
         }
     };
     await news.AddNews(list);
 }
コード例 #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            byte[] uploadedImage;
            if (fuImage.HasFile)
            {
                uploadedImage = fuImage.FileBytes;
            }
            else
            {
                if (editImage == null)
                {
                    uploadedImage = null;
                }
                else
                {
                    uploadedImage = editImage;
                }
            }

            if (String.IsNullOrEmpty(editID))
            {
                newsBusiness.AddNews(txtTitle.Text, DateTime.Parse(txtDate.Text), txtDesc.Text, uploadedImage, long.Parse(ddCategory.SelectedItem.Value));
            }
            else
            {
                newsBusiness.UpdateNews(long.Parse(editID), txtTitle.Text, DateTime.Parse(txtDate.Text), txtDesc.Text, uploadedImage, long.Parse(ddCategory.SelectedItem.Value));
            }
            Response.Redirect("News");
        }