public static Watch ToWatch(this WatchToPostDto watch)
        {
            if (watch == null)
            {
                return(null);
            }

            return(new Watch
            {
                Model = watch.Model,
                Title = watch.Title,
                Gender = watch.Gender,
                CaseSize = watch.CaseSize,
                CaseMaterial = watch.CaseMaterial,
                BrandId = watch.BrandId,
                MovementId = watch.MovementId
            });
        }
Example #2
0
        public async Task <ActionResult <WatchDto> > CreateWatchAsync(WatchToPostDto watchDto)
        {
            var created = await _watchRepository.CreateWatchAsync(watchDto.ToWatch());

            return(CreatedAtAction(nameof(GetWatchAsync), new { id = created.Id }, created.ToWatchDto()));
        }