public DbResponse <ProductQuantitySetAddReturnModel> QuantityAdd(ProductQuantityAddModel model, string vendorUserName) { try { var vendorId = _db.Registration.VendorIdByUserName(vendorUserName); if (vendorId == 0) { return(new DbResponse <ProductQuantitySetAddReturnModel>(false, "Invalid User")); } if (!_db.Product.IsProductExist(vendorId, model.ProductId)) { return(new DbResponse <ProductQuantitySetAddReturnModel>(false, "Product Not Found")); } _db.Product.QuantityAdd(model); _db.SaveChanges(); _db.Product.UpdateMainQuantity(model.ProductId); var data = new ProductQuantitySetAddReturnModel { StockQuantity = _db.Product.GetStock(model.ProductId), QuantitySet = _db.Product.GetQuantitySetDetailsById(_db.Product.ProductQuantitySet.ProductQuantitySetId) }; return(new DbResponse <ProductQuantitySetAddReturnModel>(true, "Success", data)); } catch (Exception e) { return(new DbResponse <ProductQuantitySetAddReturnModel>(false, e.Message)); } }
public IActionResult AddStock(ProductQuantityAddModel model) { var response = _product.QuantityAdd(model, User.Identity.Name); if (!response.IsSuccess) { return(UnprocessableEntity(response.Message)); } return(Json(response)); }