Exemplo n.º 1
0
    private void EatingTime()
    {
        Canteen      curCanteen = RoomManager.instance.GetClosestCanteen(this.gameObject);
        CanteenChair curChair   = curCanteen.GetChair();

        agent.SetDestination(curChair.gameObject.transform.position);
    }
Exemplo n.º 2
0
    public void SetProperties()
    {
        GameObject CanteenObject = Selection.activeGameObject;
        Canteen    canteenObj    = CanteenObject.GetComponent <Canteen>();

        canteenObj.canteenChairs = canteenObj.GetComponentsInChildren <CanteenChair>().ToList();
    }
Exemplo n.º 3
0
        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());
        }
Exemplo n.º 4
0
        public async Task <ActionResult <Canteen> > PostCanteen(Canteen canteen)
        {
            _context.Canteen.Add(canteen);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCanteen", new { id = canteen.CanteenID }, canteen));
        }
Exemplo n.º 5
0
    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));
        }
Exemplo n.º 10
0
        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());
        }
Exemplo n.º 11
0
        // 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));
        }
Exemplo n.º 12
0
        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());
        }
Exemplo n.º 13
0
        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"));
        }
Exemplo n.º 14
0
    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;
    }
Exemplo n.º 15
0
 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());
 }
Exemplo n.º 17
0
        /// <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"));
 }
Exemplo n.º 19
0
        public async Task <List <Dish> > LoadDishes(Canteen canteen)
        {
            var dishes = await GetParsed <Dishes>(CanteenUrls.FoodForCantine(canteen.Id));

            return(dishes.Dish);
        }