コード例 #1
0
ファイル: EmailController.cs プロジェクト: cameronivey/Cadre
        public IHttpActionResult SendEmail(bool isDigest)
        {
            var addresses = new List<string>();
            addresses.Add("*****@*****.**");
            MailMessage mail = new MailMessage();

            mail.From = new MailAddress("*****@*****.**");

            foreach (var address in addresses)
            {
                mail.To.Add(address);
            }

            IEmailBodyBuilder builder;
            if (isDigest)
            {
                mail.Subject = "Cadre Digest Email";
                builder = new DigestBodyBuilder();
            }
            else
            {
                mail.Subject = "Cadre Reminder Email";
                builder = new ReminderBodyBuilder();
            }

            var vmBuilder = new PostViewModelBuilder(database);

            mail.Body = builder.Build(vmBuilder.Build(database.Get<Post>()));

            AlternateView htmlView = AlternateView.CreateAlternateViewFromString(
                mail.Body, null, "text/html");

            LinkedResource logo = new LinkedResource(
                "C:/Users/Cameron/Documents/Visual Studio 2015/Projects/Cadre/Cadre/Content/logo_long.png");
            logo.ContentId = "companylogo";
            htmlView.LinkedResources.Add(logo);

            mail.AlternateViews.Add(htmlView);

            mail.IsBodyHtml = true;

            SendSmtpEmail(mail);

            return Ok();
        }
コード例 #2
0
ファイル: PostController.cs プロジェクト: cameronivey/Cadre
        public IHttpActionResult GetAllInLastMonth()
        {
            var oneMonth = new TimeSpan(30, 0, 0, 0);
            var bouttAMonthAgo = DateTime.Now.Subtract(oneMonth);
            var posts = database.Get<Post>().Where(post => post.TimeSubmitted >= bouttAMonthAgo);

            if (posts == null)
            {
                return BadRequest();
            }

            var builder = new PostViewModelBuilder(database);
            var viewModels = builder.Build(posts);

            return Ok(viewModels);
        }
コード例 #3
0
ファイル: PostController.cs プロジェクト: cameronivey/Cadre
        public IHttpActionResult GetAll()
        {
            var posts = database.Get<Post>();

            if (posts == null)
            {
                return BadRequest();
            }

            var builder = new PostViewModelBuilder(database);
            var viewModels = builder.Build(posts);

            return Ok(viewModels);
        }
コード例 #4
0
ファイル: PostController.cs プロジェクト: cameronivey/Cadre
        public IHttpActionResult GetUserPosts(int id)
        {
            var posts = database.Get<Post>().Where(post => post.Submitter.Id == id);

            if (posts == null)
            {
                return BadRequest();
            }

            var viewModels = new PostViewModelBuilder(database);

            viewModels.Build(posts);

            return Ok(posts);
        }