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));
        }
Esempio n. 2
0
        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)));
        }
Esempio n. 3
0
        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);
 }
Esempio n. 5
0
 public ActionResult Home(ProductTabModel model)
 {
     return(RedirectToAction("Index"));
 }