public async Task <ProductTabModel> AddProductTabAsync(ProductTabModel tab) { const string sql = "INSERT INTO dbo.ProductTabs (ProductId, Title, Content, IsEnabled) " + "OUTPUT INSERTED.Id, INSERTED.ProductId, INSERTED.Title, INSERTED.Content, INSERTED.IsEnabled " + "VALUES (@ProductId, @Title, @Content, @IsEnabled);"; return(await connection.QuerySingleAsync <ProductTabModel>(sql, tab)); }
public async Task <IActionResult> PostProductTabAsync([FromBody] ProductTabModel tab) { if (!await productsRepository.IsProductSellerAsync(tab.ProductId, int.Parse(User.Identity.Name))) { return(BadRequest()); } return(Ok(await productsRepository.AddProductTabAsync(tab))); }
public async Task <IActionResult> PutProductTabAsync([FromBody] ProductTabModel tab) { if (!await productsRepository.IsProductTabSellerAsync(tab.Id, int.Parse(User.Identity.Name))) { return(BadRequest()); } await productsRepository.UpdateProductTabAsync(tab); return(Ok()); }
public async Task UpdateProductTabAsync(ProductTabModel tab) { const string sql = "UPDATE dbo.ProductTabs SET Title = @Title, Content = @Content, IsEnabled = @IsEnabled " + "WHERE Id = @Id;"; await connection.ExecuteAsync(sql, tab); }
public ActionResult Home(ProductTabModel model) { return(RedirectToAction("Index")); }