public async Task <MProductTab> AddProductTabAsync(MProductTab 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 <MProductTab>(sql, tab)); }
public async Task <IActionResult> PostProductTabAsync([FromBody] MProductTab tab) { if (!User.IsInRole(RoleConstants.AdminRoleId) && !await productsRepository.IsProductSellerAsync(tab.ProductId, int.Parse(User.Identity.Name))) { return(BadRequest()); } return(Ok(await productsRepository.AddProductTabAsync(tab))); }
public async Task UpdateProductTabAsync(MProductTab tab) { const string sql = "UPDATE dbo.ProductTabs SET Title = @Title, Content = @Content, IsEnabled = @IsEnabled " + "WHERE Id = @Id;"; await connection.ExecuteAsync(sql, tab); }