Пример #1
0
        public IActionResult Put(int id, [FromBody] UnitTypeModel updatedUnitType)
        {
            var unitType = _unitTypeService.Update(updatedUnitType.ToDomainModel());

            if (unitType == null)
            {
                return(NotFound());
            }
            return(Ok(unitType.ToApiModel()));
        }
Пример #2
0
 public IActionResult Post([FromBody] UnitTypeModel unitType)
 {
     try
     {
         _unitTypeService.Add(unitType.ToDomainModel());
     }
     catch (System.Exception ex)
     {
         ModelState.AddModelError("AddUnitType", ex.GetBaseException().Message);
         return(BadRequest(ModelState));
     }
     return(CreatedAtAction("Get", new { Id = unitType.Id }, unitType));
 }