Beispiel #1
0
        public async Task <ActionResult> PostWholeSalers([FromBody] WholeSalersVM wsvm)
        {
            Whole_Salers ws = new Whole_Salers();

            // ws.Whole_Saler_ID = Convert.ToInt32(wsvm.Whole_Saler_ID);
            ws.Whole_Saler_Name                = wsvm.Whole_Saler_Name;
            ws.Whole_Saler_Buying_Cost         = wsvm.Whole_Saler_Buying_Cost;
            ws.Whole_Saler_Transportation_Cost = wsvm.Whole_Saler_Transportation_Cost;
            ws.Whole_Saler_Storing_Cost        = wsvm.Whole_Saler_Storing_Cost;
            ws.Whole_Saler_Total_Cost          = wsvm.Whole_Saler_Total_Cost;
            ws.Whole_Saler_Selling_Price       = wsvm.Whole_Saler_Selling_Price;

            db.Whole_Salers.Add(ws);

            await db.SaveChangesAsync();

            return(Ok());
        }
Beispiel #2
0
        public async Task <IActionResult> PutWholeSalers(int id, WholeSalersVM wsvm)
        {
            if (id != wsvm.Whole_Saler_ID)
            {
                return(BadRequest());
            }

            Whole_Salers ws = new Whole_Salers();

            ws.Whole_Saler_ID = Convert.ToInt32(wsvm.Whole_Saler_ID);

            ws.Whole_Saler_Name                = wsvm.Whole_Saler_Name;
            ws.Whole_Saler_Buying_Cost         = wsvm.Whole_Saler_Buying_Cost;
            ws.Whole_Saler_Transportation_Cost = wsvm.Whole_Saler_Transportation_Cost;
            ws.Whole_Saler_Storing_Cost        = wsvm.Whole_Saler_Storing_Cost;
            ws.Whole_Saler_Total_Cost          = wsvm.Whole_Saler_Total_Cost;
            ws.Whole_Saler_Selling_Price       = wsvm.Whole_Saler_Selling_Price;

            db.Entry(ws).State = EntityState.Modified;
            await db.SaveChangesAsync();

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Whole_SalersExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }