public IActionResult Post([FromBody] DeptType deptType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.DeptType.Add(deptType);

            try
            {
                _context.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (DepartmentExist(deptType.DeptTypeId))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("GetDepartment", new { id = deptType.DeptTypeId }, deptType));
        }
        public IActionResult Put(int id, [FromBody] DeptType deptType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != deptType.DeptTypeId)
            {
                return(BadRequest());
            }

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

            try
            {
                _context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DepartmentExist(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(new StatusCodeResult(StatusCodes.Status204NoContent));
        }
Exemple #3
0
    public Player()
    {
        _name   = string.Empty;
        _level  = 1;
        _dept   = DeptType.None;
        _spec   = SkillType.None;
        _skills = new Dictionary <SkillType, Skill>();

        _satisfaction   = Constants.ModBase;
        _productiveness = Constants.ModBase;

        _energy = Constants.EnergyMax;

        _xp         = 0;
        _xpRequired = CalculateXpRequired();
    }
        public IActionResult Get([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                DeptType deptType = _context.DeptType.Single(c => c.DeptTypeId == id);
                if (deptType == null)
                {
                    return(NotFound());
                }

                return(Ok(deptType));
            }
            catch (System.InvalidOperationException)
            {
                return(NotFound());
            }
        }
 public MyStoreItem(int productid, DeptType type)
 {
 }