Ejemplo n.º 1
0
        // GET api/sendmails
        public IEnumerable <EmailsHistorial> GetReportFilter([FromUri] EmailsHistorial email)
        {
            IEnumerable <EmailsHistorial> query = db.EmailHistory.ToList();

            if (!String.IsNullOrEmpty(email.De))
            {
                query = query.Where(a => a.De == email.De);
            }
            if (!String.IsNullOrEmpty(email.Para))
            {
                query = query.Where(a => a.Para == email.Para);
            }
            if (!String.IsNullOrEmpty(email.Cc))
            {
                query = query.Where(a => a.Cc == email.Cc);
            }
            if (!String.IsNullOrEmpty(email.Bcc))
            {
                query = query.Where(a => a.Cc == email.Bcc);
            }
            if (!String.IsNullOrEmpty(email.Bcc))
            {
                query = query.Where(a => a.Cc == email.Bcc);
            }
            if (!String.IsNullOrEmpty(email.Formato))
            {
                query = query.Where(a => a.Formato == email.Formato);
            }
            if (email.Fecha.Year > 1)
            {
                query = query.Where(a => a.Fecha.ToShortDateString() == email.Fecha.ToShortDateString());
            }

            return(query);
        }
Ejemplo n.º 2
0
        // POST api/sendmails
        public void Post([FromBody] EmailsHistorial email)
        {
            db.EmailHistory.Add(email);
            db.SaveChanges();
            //var countOfRows = db.EmailHistory.Count();
            //email = db.EmailHistory.OrderBy(c => 1 == 1).Skip(countOfRows - 1).FirstOrDefault();
            email.RutaArchivo = @"C:\EmailFiles\" + email.Id.ToString();
            StrategyFile strategy = new StrategyFile();

            if (email.Formato == "json")
            {
                strategy.setStrategy(new JsonStrategy(email));
            }
            else
            {
                strategy.setStrategy(new XmlStrategy(email));
            }
            strategy.createFile();
            db.Entry(email).CurrentValues.SetValues(email);
            db.SaveChanges();
        }
Ejemplo n.º 3
0
 public JsonStrategy(EmailsHistorial mail)
 {
     this.mail = mail;
 }
Ejemplo n.º 4
0
 public XmlStrategy(EmailsHistorial mail)
 {
     this.mail = mail;
 }