コード例 #1
0
        public static internalDTO.ProductName MapFromExternal(externalDTO.ProductName productName)
        {
            var res = productName == null ? null : new internalDTO.ProductName()
            {
                Id = productName.Id,
                ProductNameValue = productName.ProductNameValue
            };

            return(res);
        }
コード例 #2
0
        public async Task <IActionResult> PutProductName(int id, v1_0_DTO.ProductName productName)
        {
            if (id != productName.Id)
            {
                return(BadRequest());
            }

            _bll.ProductNames.Update(v1_0_Mapper.ProductNameMapper.MapFromExternal(productName));
            await _bll.SaveChangesAsync();

            return(NoContent());
        }
コード例 #3
0
        public async Task <ActionResult <v1_0_DTO.ProductName> > PostProductName(v1_0_DTO.ProductName productName)
        {
            productName = v1_0_Mapper.ProductNameMapper.MapFromBLL(
                await _bll.ProductNames.AddAsync(v1_0_Mapper.ProductNameMapper.MapFromExternal(productName)));

            await _bll.SaveChangesAsync();

            productName = v1_0_Mapper.ProductNameMapper.MapFromBLL(
                _bll.ProductNames.GetUpdatesAfterUOWSaveChanges(
                    v1_0_Mapper.ProductNameMapper.MapFromExternal(productName)));

            return(CreatedAtAction(nameof(GetProductName), new {
                version = HttpContext.GetRequestedApiVersion().ToString(),
                id = productName.Id
            },
                                   productName));
        }