예제 #1
0
        public async Task <IActionResult> EditPcsScoring(int id, [Bind("PcsScoringId,Score2Target,Score1Lower")] PcsScoring pcsScoring)
        {
            if (id != pcsScoring.PcsScoringId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(pcsScoring);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PcsScoringExists(pcsScoring.PcsScoringId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(pcsScoring));
        }
예제 #2
0
        public async Task <IActionResult> PutBatch(int id, Batch batch)
        {
            if (id != batch.RequestId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
예제 #3
0
        public async Task <IActionResult> PutBatch(long id, BatchDTO batchDTO)
        {
            if (id != batchDTO.Id)
            {
                return(BadRequest());
            }

            var batch = await _context.Batches.FindAsync(id);

            if (batch == null)
            {
                return(NotFound());
            }

            batch.DateUpdated = DateTime.Now;
            batch.Name        = batchDTO.Name;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException) when(!BatchExists(id))
            {
                return(NotFound());
            }

            return(NoContent());
        }
        public async Task <IActionResult> Create([Bind("ID,Name,DateStarted,ExpectedFinishDate,AmountOfWash,ExpectedWashPercent,ExpectedYield,ActualYield,PercentDiff,Notes")] Batch batch)
        {
            if (ModelState.IsValid)
            {
                _context.Add(batch);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(batch));
        }
        public async Task <IActionResult> Create([Bind("BatchReportId,OriginalReport,StreamName,Recipe,Campaign,BatchNo,WeekNo,StartTime,MakingTime,QATime,PreQaTemp,Visco,Ph,SG,Appearance,VisualColour,MeasuredColour,Odour,OverallQAStatus,StockTankAllocationTime,AllocatedTo,DropTime,TotalRecipeWeight,TotalActualWeight,VesselWeightIncrease,RecipeType,NewMakeTime")] BatchReport batchReport)
        {
            if (ModelState.IsValid)
            {
                _context.Add(batchReport);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(batchReport));
        }
예제 #6
0
        public async Task <IActionResult> Create([Bind("PcsTempTargetsId,RecipeType,Recipe,Target,UpperLimit,LowerLimit")] PcsTempTargets pcsTempTargets)
        {
            if (ModelState.IsValid)
            {
                _context.Add(pcsTempTargets);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(pcsTempTargets));
        }
예제 #7
0
        public async Task <IActionResult> Create([Bind("RecipeLimitsId,RecipeType,LimitTypes,Min,Max,GuageMax,Target,Tolerance")] RecipeLimits recipeLimits)
        {
            if (ModelState.IsValid)
            {
                _context.Add(recipeLimits);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(recipeLimits));
        }
예제 #8
0
        public async Task WriteBatchAndNumberToDatabase(BatchAndNumberFullInfo batchAndNumberFullInfo)
        {
            //I am given to understand that this is an antequated way to do this. I agree. I am however struggling to utilise the dependency injection native to EF Core, as at the top of this page.
            //Right now, I just want to focus on functionality, but please be aware that I know this is not ideal.
            var optionsBuilder = new DbContextOptionsBuilder <BatchContext>();

            optionsBuilder.UseSqlServer("Server=(local)\\sqlexpress;Database=RuanGatesBDAssessmentDB;Trusted_Connection=True;MultipleActiveResultSets=True;");

            var batch = new Batch();

            batch.BatchElements               = new List <BatchElement>();
            batch.BatchAndNumberInput         = new BatchAndNumberInput();
            batch.BatchAndNumberInput.Batches = batchAndNumberFullInfo.BatchAndNumberInputDetails.Batches;
            batch.BatchAndNumberInput.Numbers = batchAndNumberFullInfo.BatchAndNumberInputDetails.Numbers;
            batch.CollectionId = batchAndNumberFullInfo.BatchAndNumberInputDetails.RequestId;

            BatchElement batchElement = new BatchElement();

            batchElement.BatchNumber      = batchAndNumberFullInfo.BatchAndNumber.Batch;
            batchElement.NumbersRemaining = 4;
            batchElement.Aggregate        = 12;
            batchElement.NumbersInBatch   = new List <NumberInBatch>();

            NumberInBatch number = new NumberInBatch();

            number.Number = batchAndNumberFullInfo.BatchAndNumber.Number;

            batchElement.NumbersInBatch.Add(number);
            batch.BatchElements.Add(batchElement);

            batch.GrandTotal = 99;

            using (var ctx = new BatchContext(optionsBuilder.Options))
            {
                ctx.Batches.Add(batch);
                await ctx.SaveChangesAsync();
            }
        }
예제 #9
0
 public Task <int> SaveChangesAsync()
 {
     return(_batchContext.SaveChangesAsync());
 }
 public async Task SaveChangesAsync()
 {
     await _context.SaveChangesAsync();
 }