コード例 #1
0
        public ActionResult <StorageReadDto> CreateStorage(StorageCreateDto storageCreateDto)
        {
            var model = new Storage()
            {
                IdUser      = _repository.GetUserById(storageCreateDto.UserId),
                StorageName = storageCreateDto.StorageName,
            };

            _repository.CreateStorage(model);
            _repository.SaveChanges();

            var readDto = _mapper.Map <StorageReadDto>(model);

            return(CreatedAtRoute(nameof(GetStorageById), new { Id = readDto.StorageId }, readDto));
        }