Example #1
0
 public static long CreateLunchArea(LunchArea l)
 {
     using (var db = new DataContext())
     {
         if(!db.LunchAreas.Any(la => la.Name.ToLower().Equals(l.Name.ToLower())))
         {
             db.LunchAreas.Add(l);
             db.SaveChanges();
         }
     }
     return l.Id;
 }
Example #2
0
        public static long CreateLunchArea(LunchAreaCreateModel model)
        {
            var l = new LunchArea()
            {
                Description = model.Description,
                Name = model.Name,
                Url = model.Url,
                LunchAreaStatus = LunchAreaStatus.New
            };

            using (var db = new DataContext())
            {
                db.LunchAreas.Add(l);
                db.SaveChanges();
            }
            return l.Id;
        }
Example #3
0
 private static LunchAreaViewModel MapLunchAreaToModel(LunchArea l)
 {
     var model = new LunchAreaViewModel()
                     {Id = l.Id, Name = l.Name, Status = l.LunchAreaStatus.ToString(), Url = l.Url, Description = l.Description, RestaurantsCount = l.Restaurants.Count};
     return model;
 }
Example #4
0
 public void SetDataFromCompany(Company c, LunchArea area)
 {
     this.Name = c.Name;
     this.Adress = c.Adress;
     this.Company = c;
     this.Email = c.Email;
     this.Information = c.Information;
     this.Url = c.Url;
     if (!Areas.Any(a => a.Id == area.Id))
     {
         this.Areas.Add(area);
     }
 }
Example #5
0
 private static LunchAreaViewModel MapLunchAreaToViewModel(LunchArea l)
 {
     return new LunchAreaViewModel
     {
         Status = l.LunchAreaStatus.ToString(),
         Id = l.Id,
         Name = l.Name, Description = l.Description,
         Url = l.Url,
         RestaurantsCount = l.Restaurants.Count,
         //AdvertisesCount = AdminManager.get.GetAdvertisesByLunchAreaId(l.Id).Count()
     };
 }