private void EatingTime() { Canteen curCanteen = RoomManager.instance.GetClosestCanteen(this.gameObject); CanteenChair curChair = curCanteen.GetChair(); agent.SetDestination(curChair.gameObject.transform.position); }
public void SetProperties() { GameObject CanteenObject = Selection.activeGameObject; Canteen canteenObj = CanteenObject.GetComponent <Canteen>(); canteenObj.canteenChairs = canteenObj.GetComponentsInChildren <CanteenChair>().ToList(); }
public async Task <IActionResult> PutCanteen(int id, Canteen canteen) { if (id != canteen.CanteenID) { return(BadRequest()); } _context.Entry(canteen).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CanteenExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <Canteen> > PostCanteen(Canteen canteen) { _context.Canteen.Add(canteen); await _context.SaveChangesAsync(); return(CreatedAtAction("GetCanteen", new { id = canteen.CanteenID }, canteen)); }
public Canteen GetClosestCanteen(GameObject curAI) { if (canteens.Count == 1) { return(canteens[0]); } float curDistance = 0; Canteen returnCanteens = null; for (int i = 0; i < canteens.Count; i++) { float latestDistance = Vector3.Distance(curAI.transform.position, canteens[i].gameObject.transform.position); if (curDistance != 0) { if (latestDistance < curDistance) { curDistance = latestDistance; returnCanteens = canteens[i]; } } else { curDistance = latestDistance; returnCanteens = canteens[i]; } } return(returnCanteens); }
private async Task LoadDishesForCanteenAsync(Canteen canteen, bool refresh) { MODEL.IsLoadingDishes = true; MODEL.ShowDishesError = false; if (!(canteen is null)) { IEnumerable <Dish> dishes; await DishManager.INSTANCE.UpdateAsync(canteen.Id, refresh).ConfAwaitFalse(); if (MODEL.DishDate == DateTime.MaxValue) { // Load dishes for the next day when canteens are closed already anyway: DateTime date = DateTime.Now.Hour >= 15 ? DateTime.Now : DateTime.Now.AddDays(-1); MODEL.DishDate = DishManager.INSTANCE.GetNextDate(canteen.Id, date); if (MODEL.DishDate == DateTime.MaxValue) { Logger.Info($"No next dishes found for canteen '{canteen.Id}'."); MODEL.IsLoadingDishes = false; return; } } dishes = await DishManager.INSTANCE.LoadDishesAsync(canteen.Id, MODEL.DishDate).ConfAwaitFalse(); MODEL.DISHES.Replace(dishes); }
public ActionResult DeleteConfirmed(int id) { Canteen canteen = db.Canteens.Find(id); db.Canteens.Remove(canteen); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "CanteenId,CanteenName,CanteenAddress,CanteenCategoryId,ServicePrice,CanteenInfo,SendWay,ShopHours,Notice,UseTime,EvaluateNum,SellNum,Images")] Canteen canteen) { if (ModelState.IsValid) { db.Entry(canteen).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CanteenCategoryId = new SelectList(db.CanteenCategories, "CanteenCategoryId", "Value", canteen.CanteenCategoryId); return(View(canteen)); }
// GET: Admin/Canteens/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Canteen canteen = db.Canteens.Find(id); if (canteen == null) { return(HttpNotFound()); } return(View(canteen)); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Canteen = await _context.Canteen.FirstOrDefaultAsync(m => m.CanteenID == id); if (Canteen == null) { return(NotFound()); } return(Page()); }
// GET: Admin/Canteens/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Canteen canteen = db.Canteens.Find(id); if (canteen == null) { return(HttpNotFound()); } ViewBag.CanteenCategoryId = new SelectList(db.CanteenCategories, "CanteenCategoryId", "Value", canteen.CanteenCategoryId); return(View(canteen)); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Employee = HttpContext.Session.GetLogin(_context.Employee); Canteen = await _context.Canteen .Include(c => c.Company).FirstOrDefaultAsync(m => m.CanteenID == id); if (Canteen == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Canteen = await _context.Canteen.FindAsync(id); if (Canteen != null) { _context.Canteen.Remove(Canteen); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
private void FillCanteen() { Canteen canteen = inventory.FindItemsOfType <Canteen>()?[0]; if (canteen == null) // no canteen in inventory { Debug.Log("No canteen in the inventory"); //TODO: display message return; } float collectedAmount = canteen.onDrinkAmount; float limit = Mathf.Min(tankFill, canteen.capacity - canteen.currentAmount); collectedAmount = Mathf.Clamp(collectedAmount, 0f, limit); canteen.currentAmount += collectedAmount; tankFill -= collectedAmount; }
public ActionResult Create(FormCollection collection) { try { var canteenRepo = new CanteenRepo(); Canteen canteen = new Canteen { CanteenName = collection["CanteenName"], Location = collection["Location"], Phone = collection["Phone"] }; if (canteenRepo.Add(canteen)) { return(RedirectToAction("Index")); } return(View()); } catch { return(View()); } }
public ActionResult Add(Canteen u) { u.Add(); return(View()); }
/// <summary> /// Returns the rating for the given canteen if available locally. /// In case no rating is available locally, it will try to fetch it from online and caches it locally. /// </summary> /// <param name="canteen">The <see cref="Canteen"/> you want to get a rating for.</param> /// <returns>On success a valid rating or null in case something went wrong or no rating was found.</returns> public async Task <Rating> GetRatingAsync(Canteen canteen) { await Task.Delay(1000 *canteen.Name.Length); return(null); }
public ActionResult Update(Canteen Update_User) { Update_User.Canteen_MGR = (int)TempData["id"]; Update_User.update(); return(RedirectToAction("Index")); }
public async Task <List <Dish> > LoadDishes(Canteen canteen) { var dishes = await GetParsed <Dishes>(CanteenUrls.FoodForCantine(canteen.Id)); return(dishes.Dish); }