示例#1
0
        public async Task AddOrUpdateBoat(AddOrUpdateBoatInput input)
        {
            if (input.Id.HasValue)
            {
                var boat = await _repository.GetAsync(input.Id.Value);

                if (boat == null)
                {
                    throw new Exception($"No boat was found with Id of {input.Id}");
                }

                boat.Make     = input.Make;
                boat.Model    = input.Model;
                boat.Segment  = input.Segment;
                boat.Category = input.Category;

                await _repository.UpdateAsync(boat);
            }
            else
            {
                var boat = new Boat()
                {
                    Make     = input.Make,
                    Model    = input.Model,
                    Segment  = input.Segment,
                    Category = input.Category
                };

                await _repository.InsertAsync(boat);
            }
        }
 public async Task AddOrUpdate(AddOrUpdateBoatInput input)
 {
     await _boatService.AddOrUpdateBoat(input);
 }