Esempio n. 1
0
 public static long CreateAdvertise(Company c, List<LunchArea> areas, Image img)
 {
     var ad = new Advertise { Company = c, Image = img };
     using (var db = new DataContext())
     {
         c.Advertises.Add(ad);
         var dbAreas = areas.Select(a => db.LunchAreas.Find(a.Id)).ToList();
         var advertiseAreas = dbAreas.Select(a => new AdvertiseArea { LunchArea = a, Advertise = ad });
         //var advertiseAreas = areas.Select(a => new AdvertiseArea { LunchArea = a, Advertise = ad });
         foreach (var a in advertiseAreas)
         {
             ad.Areas.Add(a);
         }
         db.SaveChanges();
     }
     return ad.Id;
 }
Esempio n. 2
0
 private static AdvertiseViewModel CreateAdvertiseViewModel(Advertise a)
 {
     return new AdvertiseViewModel
     {
         Id = a.Id,
         CompanyInfo = a.Company.Information,
         CompanyName = a.Company.Name,
         CompanyUrl = a.Company.Url,
         ImageUrl = a.Image.ImageUrl
     };
 }