Esempio n. 1
0
        public async Task <IActionResult> PutShipper(int id, PublicApi.v1.DTO.Shipper shipper)
        {
            if (!ModelState.IsValid || id != shipper.Id)
            {
                return(BadRequest());
            }

            _bll.Shippers.Update(ShipperMapper.MapFromExternal(shipper));
            await _bll.SaveChangesAsync();

            return(NoContent());
        }
Esempio n. 2
0
        public async Task <ActionResult <PublicApi.v1.DTO.Shipper> > PostShipper(PublicApi.v1.DTO.Shipper shipper)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            shipper = PublicApi.v1.Mappers.ShipperMapper
                      .MapFromBLL(await _bll.Shippers.AddAsync(PublicApi.v1.Mappers.ShipperMapper.MapFromExternal(shipper)));

            await _bll.SaveChangesAsync();

            shipper = PublicApi.v1.Mappers.ShipperMapper.MapFromBLL(
                _bll.Shippers.GetUpdatesAfterUOWSaveChanges(PublicApi.v1.Mappers.ShipperMapper.MapFromExternal(shipper)));


            return(CreatedAtAction("GetShipper", new { version = HttpContext.GetRequestedApiVersion().ToString(), id = shipper.Id }, shipper));
        }