Click here to Skip to main content
15,886,069 members

To minus order quantity from inventory in ASP.NET MVC

Ugwu Chukwuka Kennedy asked:

Open original thread
Here is my problem:

For example, there are 10 quantity in hand of ProductId = 1

InventoryId | ProductId | QuantityInHand
1 | 1 | 10

Whenever a new inventory comes in, a new entry is made in PRODUCT_INVENTORY table. For example, another 15 quantity has come in, so the table would look like as follows:

InventoryId | ProductId | QuantityInHand
1 | 1 | 10
2 | 1 | 15

Now, there are 10 + 15 = 25 quantity in stock. Let's assume customer has ordered for 20 items of ProductId = 1. Since we have more quantity in stock than ordered quantity, items can be sold.

Now the question is how we should adjust the Sold Items from the table. 

Option 1 - Should we deduct 10 from the first record and 10 from the second record?
OR
Option 2 - Should we deduct 15 from the second record and 5 from the first record?

Please someone should help me solve this problem in asp.net mvc

What I have tried:

I have tried it but it giving me errors
Tags: C#, MVC, ASP.NET

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900