public async Task <ActionResult <LocomotiveTypeModel> > Create(LocomotiveTypeModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var locomotiveType = new LocomotiveType
            {
                Family       = model.Family,
                Manufacturer = model.Manufacturer,
                Name         = model.Name
            };

            await _locomotiveTypeRepository.CreateAsync(locomotiveType);

            model = _mapper.Map <LocomotiveTypeModel>(locomotiveType);

            return(CreatedAtAction(nameof(GetById), new { id = locomotiveType.Id }, model));
        }
        public async Task <ActionResult <LocomotiveTypeModel> > Update(int id, LocomotiveTypeModel model)
        {
            var locomotiveType = await _locomotiveTypeRepository.GetByIdAsync(id);

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

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            locomotiveType.Family       = model.Family;
            locomotiveType.Manufacturer = model.Manufacturer;
            locomotiveType.Name         = model.Name;

            await _locomotiveTypeRepository.UpdateAsync(locomotiveType);

            return(Ok(model));
        }