public async Task <bool> CreateETFPortfolio(ETFPortfolioCreate model) { var entity = new ETFPortfolio() { AuthorId = _userId, ETFId = model.ETFId, PortfolioId = model.PortfolioId }; using (var ctx = new ApplicationDbContext()) { var query = ctx.ETFPortfolios.Add(entity); return(await ctx.SaveChangesAsync() == 1); } }
public async Task <IHttpActionResult> PostETFPortfolio(ETFPortfolioCreate etfPort) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateETFPortfolioService(); if (await service.CreateETFPortfolio(etfPort) == false) { return(InternalServerError()); } return(Ok()); }