コード例 #1
0
        //  [Authorize(Roles = "Admin, Employee")]
        public IActionResult Create(ClassDTO newClass)
        {
            IActionResult result = null;


            try
            {
                ClassItem classItem = new ClassItem()
                {
                    Name  = newClass.Name,
                    Color = newClass.Color,
                    Date  = newClass.Date,
                };

                newClass.Id = _db.CreateClass(classItem);

                result = Ok(newClass);
            }
            catch (Exception)
            {
                result = BadRequest(new { Message = "Class not created" });
            }
            // Return the token
            return(result);
        }