Exemplo n.º 1
0
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(Customer).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CustomerExists(Customer.CustomerID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 2
0
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync(int?testChainItemID, TestActionView[] views)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            if (testChainItemID == null)
            {
                return(NotFound());
            }

            var testChainItemToUpdate = await _context.TestChainItems
                                        .Include(e => e.Operation)
                                        .Include(e => e.TestActions)
                                        .ThenInclude(e => e.Qualification)
                                        .Include(e => e.ElementType)
                                        .ThenInclude(e => e.Program)
                                        .FirstOrDefaultAsync(m => m.TestChainItemID == testChainItemID);

            if (testChainItemToUpdate == null)
            {
                return(NotFound());
            }
            testChainItemToUpdate.Description    = TestChainItem.Description;
            testChainItemToUpdate.GroupOperation = TestChainItem.GroupOperation;

            foreach (var element in testChainItemToUpdate.TestActions)
            {
                foreach (var updElement in views)
                {
                    if (element.TestActionID == updElement.TestActionID)
                    {
                        element.ItemLabor  = Decimal.Parse(updElement.ItemLabor != null ? updElement.ItemLabor : "0,00");
                        element.KitLabor   = updElement.KitLabor;
                        element.BatchLabor = updElement.BatchLabor;
                    }
                }
            }


            _context.Attach(testChainItemToUpdate).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TestChainItemExists(testChainItemToUpdate.TestChainItemID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Edit", new { testChainItemID = testChainItemToUpdate.TestChainItemID }));
        }