Example #1
0
        public void CreateAttachments(List <string> paintingIDs)
        {
            PaintingApiService ServicePainting = new PaintingApiService();


            //Purpose of LINQ: Get list of paintings and a list of selected painting ids and fill the list of mail.Attachments


            ServicePainting                                 //Service For Paintings
            .GetPaintings()                                 //Will Get A List of Paintings From API
            .Where(a => paintingIDs                         //From paintingIDs
                   .Select(int.Parse)                       //Convert Everything To INT
                   .ToList()                                //Convert To List
                   .Contains(a.PaintingId))                 //Filter Resault With The Paintings id From API
            .Select(b => b.ImageUrl)                        //Keep Only The Img Source
            .Select(c => new Attachment(LocalUrl + c))      //Create Attachment With Local URL For Every Img Scource in List
            .ToList()                                       //Convert To List, Nessesary To Add a ForEach Later
            .ForEach(d => { mail.Attachments.Add(d); });    //Add Each Attachment Created Above, Into the List Of Attachments in mail
                                                            //LINQ returns Null...so no need to save a var
        }