コード例 #1
0
        public IActionResult Put(int id, [FromBody] ActivityTypeModel updatedactivityType)
        {
            var activityType = _activityTypeService.Update(updatedactivityType.ToDomainModel());

            if (activityType == null)
            {
                return(NotFound());
            }
            return(Ok(activityType.ToApiModel()));
        }
コード例 #2
0
        public IActionResult Post([FromBody] ActivityTypeModel newActivityType)
        {
            try {
                _activityTypeService.Add(newActivityType.ToDomainModel());
            }
            catch (System.Exception ex)
            {
                ModelState.AddModelError("AddActivityType", ex.GetBaseException().Message);
                return(BadRequest(ModelState));
            }

            return(CreatedAtAction("Get", new { Id = newActivityType.Id }, newActivityType));
        }