Beispiel #1
0
        public async Task <IActionResult> AddProduct([FromBody] Inventoryes model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var postId = await _ProductRepositories1.AddProduct(model);

                    if (postId > 0)
                    {
                        _logger.LogInformation(postId.ToString());
                        return(Ok(postId));
                    }
                    else
                    {
                        _logger.LogInformation("NotFound");
                        return(NotFound());
                    }
                }
                catch (Exception ex)
                {
                    _logger.LogInformation(ex.Message);
                    return(BadRequest());
                }
            }
            return(BadRequest());
        }
Beispiel #2
0
        public async Task UpdateProduct(Inventoryes post)
        {
            if (appDbContext != null)
            {
                //Delete that post
                appDbContext.Product.Update(post);

                //Commit the transaction
                await appDbContext.SaveChangesAsync();
            }
        }
Beispiel #3
0
        public async Task <int> AddProduct(Inventoryes post)
        {
            if (appDbContext != null)
            {
                await appDbContext.Product.AddAsync(post);

                await appDbContext.SaveChangesAsync();

                return(post.PostId);
            }

            return(0);
        }
Beispiel #4
0
        public async Task <IActionResult> UpdateProduct([FromBody] Inventoryes model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    await _ProductRepositories.UpdateProduct(model);

                    return(Ok());
                }
                catch (Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException ex)
                {
                    if (ex.GetType().FullName == "Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException")
                    {
                        return(NotFound());
                    }

                    return(BadRequest());
                }
            }

            return(BadRequest());
        }
Beispiel #5
0
        public async Task <IActionResult> AddProduct([FromBody] Inventoryes model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var postId = await _ProductRepositories.AddProduct(model);

                    if (postId > 0)
                    {
                        return(Ok(postId));
                    }
                    else
                    {
                        return(NotFound());
                    }
                }
                catch (Exception)
                {
                    return(BadRequest());
                }
            }
            return(BadRequest());
        }