public async Task <IActionResult> Post(AddAssemblyComponentVM model) { var assemblyComponent = (AssemblyComponent)null; try { var assembly = await AppContext.Assemblies.FirstOrDefaultAsync(x => x.Id == model.AssemblyId); var component = await GetQuery(model.Type).FirstOrDefaultAsync(x => x.Id == model.ComponentId); var componentType = await AppContext.ComponentTypes.FirstOrDefaultAsync(x => x.Id == (int)model.Type); assemblyComponent = new AssemblyComponent { Assembly = assembly, ComponentId = component.Id, ComponentType = componentType, Quantity = model.Quantity, }; AppContext.AssemblyComponents.Add(assemblyComponent); await AppContext.SaveChangesAsync(); } catch (Exception ex) { return(BadRequest(ex)); } return(CreatedAtAction(nameof(Post), assemblyComponent)); }
public async Task <BaseApiResponse <AssemblyComponent> > Post(AddAssemblyComponentVM model) { return(await ApplicationHttpClient.HttpSendAsync <AssemblyComponent>( CombineExtension.UrlCombine(BaseUrl, Endpoint), subEndPoint, data : model, method : HttpMethod.Post)); }