Exemplo n.º 1
0
 public async Task <SupplierCommandResult> ManageSupplier(SupplierCommand cmd)
 {
     return(cmd switch
     {
         SaveSupplier c => await HandleSaveSupplier(c),
         _ => throw new NotSupportedException($"{cmd.GetType().Name} is not supported")
     });
Exemplo n.º 2
0
        private SupplierDocument GetSupplierDetails(string supplierName)
        {
            var receiver = new SupplierCommand(supplierName, $"{GetResourceServerAddress()}?cn={supplierName}");
            var document = receiver.Execute();

            return(document.Data.Message);
        }
        public async Task <ActionResult <SupplierCommand> > PostSupplierCommand(SupplierCommand supplierCommand)
        {
            _context.SupplierCommands.Add(supplierCommand);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSupplierCommand", new { id = supplierCommand.Id }, supplierCommand));
        }
        protected static SupplierDocument GetSupplierFromErpNext(string name)
        {
            var receiver         = new SupplierCommand(name, $"{GetSupplierResourceServerAddress()}");
            var supplierDocument = receiver.Execute();

            return(supplierDocument.Data.Message);
        }
        public async Task <IActionResult> PutSupplierCommand(int id, SupplierCommand supplierCommand)
        {
            if (id != supplierCommand.Id)
            {
                return(BadRequest());
            }

            _context.Entry(supplierCommand).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SupplierCommandExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }