Ejemplo n.º 1
0
        public async Task <IActionResult> PutProductDosage(int id, v1_0_DTO.ProductDosage productDosage)
        {
            if (id != productDosage.Id)
            {
                return(BadRequest());
            }

            _bll.ProductDosages.Update(v1_0_Mapper.ProductDosageMapper.MapFromExternal(productDosage));
            await _bll.SaveChangesAsync();

            return(NoContent());
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <v1_0_DTO.ProductDosage> > PostProductDosage(v1_0_DTO.ProductDosage productDosage)
        {
            productDosage = v1_0_Mapper.ProductDosageMapper.MapFromBLL(
                await _bll.ProductDosages.AddAsync(v1_0_Mapper.ProductDosageMapper.MapFromExternal(productDosage)));
            await _bll.SaveChangesAsync();

            productDosage = v1_0_Mapper.ProductDosageMapper.MapFromBLL(
                _bll.ProductDosages.GetUpdatesAfterUOWSaveChanges(
                    v1_0_Mapper.ProductDosageMapper.MapFromExternal(productDosage)));

            return(CreatedAtAction("GetProductDosage", new { version = HttpContext.GetRequestedApiVersion().ToString(), id = productDosage.Id }, productDosage));
        }
        public static internalDTO.ProductDosage MapFromExternal(externalDTO.ProductDosage productDosage)
        {
            var res = productDosage == null ? null : new internalDTO.ProductDosage()
            {
                Id        = productDosage.Id,
                DosageId  = productDosage.DosageId,
                Dosage    = DosageMapper.MapFromExternal(productDosage.Dosage),
                ProductId = productDosage.ProductId,
                Product   = ProductMapper.MapFromExternal(productDosage.Product)
            };

            return(res);
        }