Exemple #1
0
        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));
        }
Exemple #2
0
        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)));
        }
Exemple #3
0
 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);
 }