Exemple #1
0
 public void AddOutreach(OutreachDTO entry, string user)
 {
     p1p.Data.Link link;
     p1p.Data.Link linkMatch;
     entry.AddedBy    = user;
     entry.InsertDate = DateTime.Now;
     p1p.Data.Outreach mdlOutreach = (p1p.Data.Outreach)P1PObjectMapper.Convert(entry, typeof(p1p.Data.Outreach));
     using (p1p.Data.P1PContext ctx = new p1p.Data.P1PContext())
     {
         if (entry.OutreachAction != null && ctx.OutreachActions.FirstOrDefault(oa => oa.Id == entry.OutreachAction.Id) != null)
         {
             linkMatch             = ctx.Links.Single(l => entry.LinkId == l.Id);
             link                  = linkMatch;
             link.LastModifiedBy   = user;
             link.DateLastModified = DateTime.Now;
             ctx.Outreaches.Add(mdlOutreach);
             ctx.Entry(linkMatch).CurrentValues.SetValues(link);
             ctx.SaveChanges();
         }
         else
         {
             throw new Exception("You must select an outreach action to save this outreach.");
         }
     }
 }
Exemple #2
0
 public OutreachDTO UpdateOutreach(OutreachDTO entry)
 {
     p1p.Data.Outreach mdlOutreach = (p1p.Data.Outreach)P1PObjectMapper.Convert(entry, typeof(p1p.Data.Outreach));
     p1p.Data.Outreach match;
     using (p1p.Data.P1PContext ctx = new p1p.Data.P1PContext())
     {
         match = ctx.Outreaches.Single(e => entry.Id == e.Id);
         ctx.Entry(match).CurrentValues.SetValues(mdlOutreach);
         ctx.SaveChanges();
         return((OutreachDTO)P1PObjectMapper.Convert(match, typeof(OutreachDTO)));
     }
 }
Exemple #3
0
        public void DeleteOutreach(int entryId)
        {
            using (p1p.Data.P1PContext ctx = new p1p.Data.P1PContext())
            {
                p1p.Data.Outreach entry = ctx.Outreaches.Single(w => entryId == w.Id);

                if (entry != null)
                {
                    ctx.Outreaches.Remove(entry);
                    ctx.SaveChanges();
                }
            }
        }