public async Task <IHttpActionResult> PutSatisfactionLevel(int id, SatisfactionLevel satisfactionLevel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != satisfactionLevel.Id)
            {
                return(BadRequest());
            }

            db.Entry(satisfactionLevel).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SatisfactionLevelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <ActionResult <SatisfactionLevel> > PostSatisfactionLevel(SatisfactionLevel satisfactionLevel)
        {
            _context.SatisfactionLevels.Add(satisfactionLevel);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSatisfactionLevel", new { id = satisfactionLevel.Id }, satisfactionLevel));
        }
        public async Task <IActionResult> PutSatisfactionLevel(int id, SatisfactionLevel satisfactionLevel)
        {
            if (id != satisfactionLevel.Id)
            {
                return(BadRequest());
            }

            _context.Entry(satisfactionLevel).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SatisfactionLevelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
 public StatelessSatisfactionServiceIncreaseTests(int moodChangeEvery, int secondsSinceLastInteraction,
                                                  SatisfactionLevel startLevel, SatisfactionLevel expectedLevel)
 {
     _moodChangeEvery             = moodChangeEvery;
     _secondsSinceLastInteraction = secondsSinceLastInteraction;
     _startLevel    = startLevel;
     _expectedLevel = expectedLevel;
 }
Esempio n. 5
0
    public override void UpdateSatisfaction(SatisfactionLevel satisfactionLevel)
    {
        if (!satisfactionSpriteDict.TryGetValue(satisfactionLevel, out Sprite sprite))
        {
            Debug.LogErrorFormat(name + " | failed to pull {0} sprite from dictionary", satisfactionLevel);
            return;
        }

        // Set sprite accordingly
        image.sprite = sprite;
    }
        public async Task <IHttpActionResult> GetSatisfactionLevel(int id)
        {
            SatisfactionLevel satisfactionLevel = await db.SatisfactionLevels.FindAsync(id);

            if (satisfactionLevel == null)
            {
                return(NotFound());
            }

            return(Ok(satisfactionLevel));
        }
        public async Task <IHttpActionResult> PostSatisfactionLevel(SatisfactionLevel satisfactionLevel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.SatisfactionLevels.Add(satisfactionLevel);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = satisfactionLevel.Id }, satisfactionLevel));
        }
        public async Task <IHttpActionResult> DeleteSatisfactionLevel(int id)
        {
            SatisfactionLevel satisfactionLevel = await db.SatisfactionLevels.FindAsync(id);

            if (satisfactionLevel == null)
            {
                return(NotFound());
            }

            db.SatisfactionLevels.Remove(satisfactionLevel);
            await db.SaveChangesAsync();

            return(Ok(satisfactionLevel));
        }
Esempio n. 9
0
    public override void UpdateSatisfaction(SatisfactionLevel satisfactionLevel)
    {
        // Pull number of icons from dictionary
        if (!satisfactionIconCountDict.TryGetValue(satisfactionLevel, out int numberOfIcons))
        {
            Debug.LogErrorFormat(name + " | failed to pull {0} number of icons from dictionary", satisfactionLevel);
            return;
        }

        // Ignore if satisfaction level hasn't changed
        if (satisfactionLevel == this.satisfactionLevel)
        {
            return;
        }

        // Remember it so we don't update until it changes
        this.satisfactionLevel = satisfactionLevel;

        RefreshChildren(numberOfIcons);
    }
 private void UpdateSatisfactionLevel()
 {
     if ((otherGarbageLevel / maxOtherGarbageLevel) >= wasteTolleranceHigh)
     {
         // most problems
         mySatisfcationLevel = SatisfactionLevel.NONE;
     }
     else if ((otherGarbageLevel / maxOtherGarbageLevel) >= wasteTolleranceMedium)
     {
         // more problems
         mySatisfcationLevel = SatisfactionLevel.LOW;
     }
     else if ((otherGarbageLevel / maxOtherGarbageLevel) >= wasteTolleranceLow)
     {
         // some problems
         mySatisfcationLevel = SatisfactionLevel.MEDIUM;
     }
     else if ((otherGarbageLevel / maxOtherGarbageLevel) < wasteTolleranceLow)
     {
         // no problems
         mySatisfcationLevel = SatisfactionLevel.HIGH;
     }
 }
Esempio n. 11
0
 /// <summary>
 /// Updates UI according to satisfaction level
 /// </summary>
 /// <param name="satisfactionLevel"></param>
 public abstract void UpdateSatisfaction(SatisfactionLevel satisfactionLevel);