public async Task <ActionResult <VendorOut> > UpdateVendor(VendorIn vendorIn)
        {
            try
            {
                var vendorDTO = m_Context.GetVendor(vendorIn.ID);
                vendorDTO.CopyFrom(vendorIn);

                await UpdateVendor(vendorDTO.ID, vendorDTO);

                return(new VendorOut(m_Context, vendorDTO));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                throw;
            }
        }
Пример #2
0
        public async Task <ActionResult <VendorOut> > PostVendor([FromForm] VendorIn vendorIn)
        {
            try
            {
                if (vendorIn.ID == 0)
                {
                    return(await m_Handler.AddNewVendor(vendorIn));
                }

                return(await m_Handler.UpdateVendor(vendorIn));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                throw;
            }
        }
        public async Task <ActionResult <VendorOut> > AddNewVendor([FromForm] VendorIn vendorIn)
        {
            try
            {
                VendorDTO vendorDTO = new VendorDTO(vendorIn);
                m_Context.Vendors.Add(vendorDTO);
                await m_Context.SaveChangesAsync();

                vendorDTO = m_HttpController.CreatedAtAction("GetProduct", new { id = vendorDTO.ID }, vendorDTO).Value as VendorDTO;

                await m_HttpController.PutVendor(vendorDTO.ID, vendorDTO);

                return(new VendorOut(m_Context, vendorDTO));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                throw;
            }
        }
Пример #4
0
 public VendorDTO(VendorIn In)
     : base(In)
 {
 }