public List<AgregClientEmailingModel> GetClientEmailingsByCgp(Guid idcgp)
        {
            using (Data.Model.UpsilabEntities context = new UpsilabEntities())
            {
                var _models = new List<AgregClientEmailingModel>();
                var emailings = context.ag_upsideo_clientemailing.Where(x => x.idcgp == idcgp && (x.deleted == null || x.deleted == "n"));

                foreach (var emailing in emailings)
                {
                    var model = new AgregClientEmailingModel
                    {
                        A = emailing.a,
                        Cc = emailing.cc,
                        DateCreation = emailing.datecreation.HasValue ? emailing.datecreation.Value : DateTime.MinValue,
                        IdClientEmailing = emailing.idemailingclient,
                        IsDraft = emailing.draft.HasValue ? emailing.draft.Value : false,
                        Message = emailing.message,
                        Objet = emailing.objet,
                        Files = emailing.ag_upsideo_clientemailing_attachedfile.Where(x => x.deleted == null || x.deleted == "n").Select(x => new AgregClientEmailingModel.AttachedFile { IdAttached = x.idattachedfile, Filename = x.name, Location = x.location }).ToList()
                    };
                    _models.Add(model);
                }    

                return _models;
            }
        }
 public int Add(AgregClientEmailingModel emailing)
 {
     var files = emailing.Files.ToDictionary(x => x.Filename, x => x.Location);
     return Add(emailing.IdClientEmailing, emailing.IdCgp, emailing.A, emailing.Cc, emailing.Objet, emailing.Message, files, emailing.IsDraft);
 }