// CREATE public async Task AddRestaurantAsync(DL.Restaurant item) { using (var db = new LocalGourmetDBEntities()) { db.Restaurants.Add(item); await db.SaveChangesAsync(); } }
public static DL.Restaurant LibraryToData(BLL.Models.Restaurant libModel) { var dataModel = new DL.Restaurant(); { dataModel.ID = libModel.ID; dataModel.Name = libModel.Name; dataModel.Location = libModel.Location; dataModel.Cuisine = libModel.Cuisine; dataModel.Specialty = libModel.Specialty; dataModel.PhoneNumber = libModel.PhoneNumber; dataModel.WebAddress = libModel.WebAddress; dataModel.Type = libModel.Type; dataModel.Hours = libModel.Hours; dataModel.Active = libModel.Active; }; return(dataModel); }
public static BLL.Models.Restaurant DataToLibrary(DL.Restaurant dataModel) { int restID = dataModel.ID; List <Review> revs = Review.GetReviewsByRestaurantID(restID); var libModel = new BLL.Models.Restaurant() { ID = dataModel.ID, Name = dataModel.Name, Location = dataModel.Location, Cuisine = dataModel.Cuisine, Specialty = dataModel.Specialty, PhoneNumber = dataModel.PhoneNumber, WebAddress = dataModel.WebAddress, Type = dataModel.Type, Hours = dataModel.Hours, Active = dataModel.Active, Reviews = revs // Eager loading }; return(libModel); }
// CREATE public async Task AddRestaurantAsync() { DL.Restaurant restaurant = LibraryToData(this); RestaurantAccessor ra = new RestaurantAccessor(); await ra.AddRestaurantAsync(restaurant); }