Пример #1
0
        public async Task <IActionResult> PutUnidade(int id, Unidade unidade)
        {
            if (id != unidade.Id)
            {
                return(BadRequest());
            }

            _context.Entry(unidade).State = EntityState.Modified;

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

            return(NoContent());
        }
Пример #2
0
        public async Task <IActionResult> PutAmostra(int id, Amostra amostra)
        {
            if (id != amostra.Id)
            {
                return(BadRequest());
            }

            _context.Entry(amostra).State = EntityState.Modified;

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

            return(NoContent());
        }
Пример #3
0
        public async Task <IActionResult> PutPadrao(int id, Padrao padrao)
        {
            if (id != padrao.Id)
            {
                return(BadRequest());
            }

            _context.Entry(padrao).State = EntityState.Modified;

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

            return(NoContent());
        }
Пример #4
0
        public async Task <int> SavePurchaseOrderRequest(PurchaseOrderRequestModel model)
        {
            if (model.Id == 0)
            {
                // var samples = model.Samples;
                // var quotation = model.Quotation;
                // model.Samples = null;
                // model.Quotation = null;
                // model.ReceivedFrom = null;
                // model.SubmittedBy = null;
                model.SubmittedById = 1;

                //add ModifiedPrice if missing from TestParameterMehtod reverting to the default price. and add PORId
                if (model.Samples != null)
                {
                    foreach (SampleModel sample in model.Samples)
                    {
                        //sample.PurchaseOrderRequestId = model.Id;
                        // var testParameters = sample.SampleTestParameters;
                        // sample.SampleTestParameters = null;
                        sample.ReceivedByUserId = 1;
                        // await db.Samples.AddAsync(sample);
                        // await db.SaveChangesAsync();

                        if (sample.SampleTestParameters == null)
                        {
                            continue;
                        }
                        foreach (SampleTestParameterModel testParameter in sample.SampleTestParameters)
                        {
                            testParameter.SampleId = sample.Id;
                            TestParameterMethodModel testParameterMethod = await db.TestParameterMethods.SingleAsync(t => t.TestParameterId == testParameter.TestParameterId && t.MethodId == testParameter.MethodId);

                            testParameter.TestParameterMethodId = testParameterMethod.Id;
                            if (testParameter.ModifiedPrice <= 0)
                            {
                                testParameter.ModifiedPrice = testParameterMethod.Price;
                            }
                        }

                        // await db.SampleTestParameters.AddRangeAsync(testParameters);
                        // await db.SaveChangesAsync();
                    }
                }

                db.PurchaseOrderRequests.Add(model);
                await db.SaveChangesAsync();
            }
            else
            {
                var origModel = await db.PurchaseOrderRequests.Include(p => p.Samples).Include(p => p.Quotation).SingleAsync(p => p.Id == model.Id);

                //what is this ??
                origModel = model;
            }
            //await db.SaveChangesAsync();
            return(model.Id);
        }
Пример #5
0
        public async Task <TestParameterModel> SaveTestAsync(TestParameterModel test)
        {
            if (test.Id == 0)
            {
                await db.TestParameters.AddAsync(test);
            }
            else
            {
                db.Update(test);
            }

            await db.SaveChangesAsync();

            return(test);
        }