public Sprite GetRestaurantOutside(RestaurantType r) { string typeName = ""; //only some of these have been implemented so far switch (r) { case RestaurantType.Catfe: typeName = "Catfe"; break; case RestaurantType.Italian: typeName = "Pizza"; break; case RestaurantType.Burger: typeName = "Burger"; break; default: typeName = "Catfe"; break; } return(restaurantSprites[restaurantSpriteNames.IndexOf(Variables.RESTAURANT_SPRITE_STRING + typeName)]); }
public async Task <ActionResult <RestaurantType> > PostRestaurantType(RestaurantType restaurantType) { _context.RestaurantType.Add(restaurantType); await _context.SaveChangesAsync(); return(CreatedAtAction("GetRestaurantType", new { id = restaurantType.id }, restaurantType)); }
public ICollection <Restaurant> GetRestaurantsFull(string search, string type) { ICollection <Restaurant> restaurants; using (ApplicationDbContext db = new ApplicationDbContext()) { var query = db.Restaurants.Include("Type") .Include("Menu") .Include("Tables") .Include("Manager") .Include("Images") .AsQueryable(); if (!String.IsNullOrEmpty(search)) { query = query.Where(x => x.CompanyName.Contains(search)); } if (!String.IsNullOrEmpty(type)) { RestaurantType searchType = db.RestaurantTypes.Find(type); query = query.Where(x => x.Type.Any(y => y.Name == searchType.Name)); } restaurants = query.ToList(); } return(restaurants); }
public bool AddRestaurantType(RestaurantTypeDto restaurantTypeDto, long userId) { ValidateRestaurantType(restaurantTypeDto); RestaurantType restaurantType = new RestaurantType(); restaurantType.RestaurantTypeId = _restaurantTypeService.GetLastRecordId() + 1; restaurantType.RestaurantTypeTranslations = new List <RestaurantTypeTranslation>(); //foreach (var type in restaurantTypeDto.TypeName) //{ foreach (var typeName in restaurantTypeDto.TypeNameDictionary) { if (_restaurantTypeTranslationService.CheckRepeatedType(typeName.Value, typeName.Key, restaurantType.RestaurantTypeId, userId)) { throw new ValidationException(ErrorCodes.RestaurantTypeAlreadyExist); } restaurantType.RestaurantTypeTranslations.Add(new RestaurantTypeTranslation { Language = typeName.Key.ToLower(), TypeName = typeName.Value, RestaurantTypeId = restaurantType.RestaurantTypeId }); } //} restaurantType.AdminId = userId; _restaurantTypeTranslationService.InsertRange(restaurantType.RestaurantTypeTranslations); _restaurantTypeService.Insert(restaurantType); SaveChanges(); return(true); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Remarks,Name")] RestaurantType restaurantType) { if (id != restaurantType.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(restaurantType); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RestaurantTypeExists(restaurantType.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(restaurantType)); }
public bool CreateRestaurant(Restaurant restaurant, List <string> typeIds) { bool result; using (ApplicationDbContext db = new ApplicationDbContext()) { Restaurant rest = db.Restaurants.Find(restaurant.RestaurantId); if (rest == null) { db.Restaurants.Add(restaurant); db.SaveChanges(); foreach (string typeId in typeIds) { RestaurantType type = db.RestaurantTypes.Find(typeId); if (type != null) { restaurant.Type.Add(type); } } db.SaveChanges(); result = true; } else { result = false; } } return(result); }
public DayTrip( ActivityType morningActivity, RestaurantType lunch, ActivityType afternoonActivity, RestaurantType dinner, ActivityType eveningActivity, AccommodationType?accommodation, TransportType transport, ClientType client) { _activities = new List <ActivityType> { morningActivity, afternoonActivity, eveningActivity }; _lunch = lunch; _dinner = dinner; _transport = transport; _client = client; if (_client == ClientType.InternationalVisitor && accommodation == null) { throw new ArgumentNullException(nameof(accommodation), "International visitor must have accommodation"); } _accommodation = accommodation; }
public async Task <IActionResult> PutRestaurantType(int id, RestaurantType restaurantType) { if (id != restaurantType.id) { return(BadRequest()); } _context.Entry(restaurantType).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RestaurantTypeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult DeleteConfirmed(int id) { RestaurantType restaurantType = db.RestaurantTypes.Find(id); db.RestaurantTypes.Remove(restaurantType); db.SaveChanges(); return(RedirectToAction("Index")); }
public RestaurantData(ItemInstance i) { type = RestaurantType.Catfe; waiters = new List <WaiterData>(); chefs = new List <ChefData>(); decor = new List <DecorationData>(); utensils = new List <CookingUtensil>(); location = 1; }
public IActionResult RestaurantTypeEdit(RestaurantTypeEditViewModel model) { RestaurantType type = new RestaurantType { Naam = model.Naam }; _service.Update(type, model.Id); return(RedirectToAction("RestaurantTypeList")); }
public IActionResult RestaurantTypeEdit(int id) { RestaurantType typeFromDb = _service.Get(id); RestaurantTypeEditViewModel vm = new RestaurantTypeEditViewModel() { Naam = typeFromDb.Naam }; return(View(vm)); }
public IActionResult RestaurantTypeCreate(RestaurantTypeCreateViewModel model) { RestaurantType restaurantType = new RestaurantType { Naam = model.Naam }; _service.Insert(restaurantType); return(RedirectToAction("RestaurantTypeList")); }
public ActionResult Edit([Bind(Include = "Id,Name,Description")] RestaurantType restaurantType) { if (ModelState.IsValid) { db.Entry(restaurantType).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(restaurantType)); }
public void Update(RestaurantType type, int id) { RestaurantType typeToUpdate = Get(id); if (typeToUpdate != null) { typeToUpdate.Naam = type.Naam; _context.SaveChanges(); } }
public ActionResult CreateRestaurantType(RestaurantType type) { if (!ModelState.IsValid || type.Name == null) { TempData["Message"] = "Name Can't be Empty!"; return(View(type)); } rtDb.CreateRestaurantType(type); return(RedirectToAction("RestaurantTypeIndex")); }
public async Task <IActionResult> Create([Bind("Id,Remarks,Name")] RestaurantType restaurantType) { if (ModelState.IsValid) { _context.Add(restaurantType); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(restaurantType)); }
public ActionResult Create([Bind(Include = "Id,Name,Description")] RestaurantType restaurantType) { if (ModelState.IsValid) { db.RestaurantTypes.Add(restaurantType); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(restaurantType)); }
public RestaurantData(RestaurantType rt) { tables = new List <int>(); type = rt; waiters = new List <WaiterData>(); chefs = new List <ChefData>(); decor = new List <DecorationData>(); utensils = new List <CookingUtensil>(); stars = 0; starProgress = 0f; minigamesCompleted = 0; }
public async Task <bool> DeleteByRestaurantType(RestaurantType type) { try { await _context.Restaurants.DeleteManyAsync(r => r.Type.Equals(type)); } catch { return(false); } return(true); }
// GET: RestaurantTypes/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RestaurantType restaurantType = db.RestaurantTypes.Find(id); if (restaurantType == null) { return(HttpNotFound()); } return(View(restaurantType)); }
public async Task <RestaurantType> DeleteRestaurantType(int restaurantTypeId) { RestaurantType dbEntry = dbContext.RestaurantTypes.Find(restaurantTypeId); if (dbEntry == null) { throw new InvalidOperationException("Type not found"); } dbContext.RestaurantTypes.Remove(dbEntry); await dbContext.SaveChangesAsync(); return(dbEntry); }
public async Task <int> SaveRestaurantType(RestaurantType restaurantType) { if (restaurantType == null) { throw new ArgumentNullException(nameof(restaurantType), "Parameter is null"); } if (restaurantType.Id == 0) { dbContext.RestaurantTypes.Add(restaurantType); } await dbContext.SaveChangesAsync(); return(restaurantType.Id); }
public SupplyResponse AddRestaurantType([FromBody] RestaurantType nameRequest) { if (string.IsNullOrWhiteSpace(nameRequest.RestaurantTypeName)) { return(SupplyResponse.RequiredFieldEmpty()); } var restaurantType = new RestaurantType { RestaurantTypeName = nameRequest.RestaurantTypeName }; var entity = _dbContext.RestaurantType.Add(restaurantType); _dbContext.SaveChanges(); return(SupplyResponse.Ok(entity.Entity)); }
public bool CreateRestaurantType(RestaurantType type) { bool result; using (ApplicationDbContext db = new ApplicationDbContext()) { if (db.RestaurantTypes.Find(type.Name) == null) { db.RestaurantTypes.Add(type); db.SaveChanges(); result = true; } else { result = false; } } return(result); }
public static ChefData GenerateChef() { GenerateSharedData(); specialties = new List <RestaurantType>(); //the number of specialties that come default dedpend on the rarity //the # of specialites is rarity - 1, so 2 star gets 1, 3 star gets 2, etc. for (int i = rarity; i > 1; i--) { RestaurantType temp = GetRandomRestaurantType(); //this is to prevent having the same specialty twice while (specialties.Contains(temp)) { temp = GetRandomRestaurantType(); } specialties.Add(temp); } return(new ChefData(name, rarity, sprites, income, specialties)); }
public void UpdateRestaurant(Restaurant restaurant, List <string> typeIds) { using (ApplicationDbContext db = new ApplicationDbContext()) { db.Restaurants.Attach(restaurant); db.Entry(restaurant).Collection("Type").Load(); restaurant.Type.Clear(); db.SaveChanges(); foreach (string typeId in typeIds) { RestaurantType type = db.RestaurantTypes.Find(typeId); if (type != null) { restaurant.Type.Add(type); } } db.Entry(restaurant).State = EntityState.Modified; db.SaveChanges(); } }
private Restaurant CreateTestRestaurant(string name, RestaurantType type, string foodType, double averagePrices, string hours, string address, string pic, bool alcohol, string website, string phone, bool delivery, string yelp) { var user1 = _userManager.FindByNameAsync("*****@*****.**").Result; var user2 = _userManager.FindByNameAsync("*****@*****.**").Result; return(new Restaurant { RestaurantName = name, RestaurantType = type, FoodType = foodType, PriceRange = averagePrices, HoursOfOperation = hours, Address = address, Image = pic, Alcohol = alcohol, RestaurantWebsite = website, PhoneNumber = phone, DeliveryService = delivery, YelpJSON = yelp, UserReviews = new List <Review> { new Review { UserId = user1.Id, ReviewTitle = "Generic Review 1", RestaurantId = 1, UserReview = "Blegh its to generic", UserScore = 2, }, new Review { UserId = user2.Id, ReviewTitle = "Generic Review 2", RestaurantId = 1, UserReview = "Blegh its super generic", UserScore = 1, }, } }); }
public SupplyResponse EditestaurantType(int id, [FromBody] RestaurantType nameRequest) { if (id == 0) { return(SupplyResponse.RequiredFieldEmpty()); } if (string.IsNullOrWhiteSpace(nameRequest.RestaurantTypeName)) { return(SupplyResponse.RequiredFieldEmpty()); } var restaurantType = _dbContext.RestaurantType.SingleOrDefault(p => p.RestaurantTypeId == id); if (restaurantType == null) { return(SupplyResponse.NotFound("restaurant type", "" + id)); } restaurantType.RestaurantTypeName = nameRequest.RestaurantTypeName; _dbContext.SaveChanges(); return(SupplyResponse.Ok(Get())); }
public void MakeNewRestaurant(RestaurantType r) { newRestaurantCanvas.SetActive(false); Debug.Log("You've made a new restaurant of type " + r); GameObject newRest = (GameObject)Instantiate(newRestaurantPrefab); newRest.transform.position = location; //getting the correct sprite //newRest.GetComponent<Restaurant>().title.sprite = GetRestaurantOutside(r); //saving the location that the restaurant is in int loc = -1; int i = 0; while (loc == -1) { if (restaurantLocations[i] == location) { loc = i; } i++; } newRest.GetComponent <Restaurant>().data.location = loc; newRest.GetComponent <Restaurant>().data.type = r; newRest.transform.SetParent(restaurantLocationsParent.transform); //PlayerData.playerData.restaurants.Add(newRest.GetComponent<Restaurant>().data); //adding in the restaurant into the user's inventory PurchaseItemRequest request = new PurchaseItemRequest(); request.ItemId = "catfe"; request.CatalogVersion = "Items"; request.VirtualCurrency = "NM"; request.Price = 0; PlayFabClientAPI.PurchaseItem(request, result => { }, error => { Debug.LogError(error.ErrorMessage); }); }