private void OnFoodEvent(FoodEvent foodEvent)
        {
            var worldSize = foodEvent.WorldSize;
            var eventType = foodEvent.EventType;

            lock (_foodUpdateQueue)
            {
                foreach (var blob in foodEvent.Blobs)
                {
                    _foodUpdateQueue.Enqueue(new BlobToUpdate(blob, eventType, worldSize));
                }
            }
        }
Пример #2
0
        public async Task <IActionResult> Create(int id, [Bind("EmployeeName,EmployeeEID,EventDate,Department,BudgetNumbers,BudgetType,BudgetPurpose,Note,Item1,Item2,item3,Item4,Item5,Item6,Item7,Total,Justification,EventDescription")] FoodEvent foodEvent)
        {
            if (ModelState.IsValid)
            {
                foodEvent.CaseID = id;
                _context.Add(foodEvent);
                await _context.SaveChangesAsync();

                var cid = id;
                return(RedirectToAction("Details", "Cases", new { id = cid, area = "" }));
                //return RedirectToAction("Index", "Home");
            }
            return(View(foodEvent));
        }
Пример #3
0
        public async Task <IActionResult> Edit(int id, [Bind("CaseID,EmployeeName,EmployeeEID,EventDate,Department,BudgetNumbers,BudgetType,BudgetPurpose,Note,Item1,Item2,item3,Item4,Item5,Item6,Item7,Total,Justification,EventDescription")] FoodEvent foodEvent)

        {
            if (id != foodEvent.CaseID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    IQueryable <FoodEvent> beforeCases = _context.FoodEvent.Where(c => c.CaseID == id).AsNoTracking <FoodEvent>();
                    FoodEvent beforeCase = beforeCases.FirstOrDefault();
                    if (beforeCase == null)
                    {
                        return(NotFound());
                    }
                    else
                    {
                        // Creating an audit log
                        var audit = new CaseAudit {
                            AuditLog = "Case Specific Details Edited", CaseID = id, LocalUserID = User.Identity.Name
                        };
                        _context.Add(audit);
                        await _context.SaveChangesAsync();

                        // Adding old details to tracking
                        var old_details = new FoodEventTracking
                        {
                            Status           = "old",
                            CaseAuditID      = audit.CaseAuditID,
                            CaseID           = beforeCase.CaseID,
                            EventDescription = beforeCase.EventDescription,
                            EmployeeName     = beforeCase.EmployeeName,
                            EventDate        = beforeCase.EventDate,
                            Department       = beforeCase.Department,
                            BudgetNumbers    = beforeCase.BudgetNumbers,
                            BudgetPurpose    = beforeCase.BudgetPurpose,
                            BudgetType       = beforeCase.BudgetType,
                            Total            = beforeCase.Total
                        };
                        _context.Add(old_details);
                        // Adding current details to tracking
                        var new_details = new FoodEventTracking
                        {
                            Status           = "new",
                            CaseAuditID      = audit.CaseAuditID,
                            CaseID           = foodEvent.CaseID,
                            EventDescription = foodEvent.EventDescription,
                            EmployeeName     = foodEvent.EmployeeName,
                            Department       = foodEvent.Department,
                            EventDate        = foodEvent.EventDate,
                            BudgetNumbers    = foodEvent.BudgetNumbers,
                            BudgetPurpose    = foodEvent.BudgetPurpose,
                            BudgetType       = foodEvent.BudgetType,
                            Total            = foodEvent.Total
                        };
                        _context.Add(new_details);
                        // Adding current details to actual Case Type entity
                        _context.Update(foodEvent);
                        await _context.SaveChangesAsync();
                    }
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FoodEventExists(foodEvent.CaseID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                var cid = id;
                return(RedirectToAction("Details", "Cases", new { id = cid, area = "" }));
            }
            return(View(foodEvent));
        }
Пример #4
0
 private void Start()
 {
     foodEvent        = new FoodEvent();
     foodEvent.onEat += new FoodEvent.foodHandler(onEatFood);
 }