Ejemplo n.º 1
0
        public async Task OnPostEditAsync()
        {
            Supplier ExistingRecord = await _context.Supplier.FirstOrDefaultAsync(m => m.Id == Supplier.Id);

            if (ExistingRecord == null)
            {
                //If the supplier doesn't exist I want to add it, but this isn't working quite yet.
                //_context.Supplier.Add(Supplier);
            }
            else
            {
                ExistingRecord.SupplierNo   = Supplier.SupplierNo;
                ExistingRecord.CreateDate   = Supplier.CreateDate;
                ExistingRecord.Creator      = Supplier.Creator;
                ExistingRecord.ReopenDate   = Supplier.ReopenDate;
                ExistingRecord.StatusId     = Supplier.StatusId;
                ExistingRecord.CategoryId   = Supplier.CategoryId;
                ExistingRecord.EscalationId = Supplier.EscalationId;

                _context.Attach(ExistingRecord).State = EntityState.Modified;
            }
            await _context.SaveChangesAsync();

            StatusMessage = "Saved!";
            await OnGetAsync();
        }
Ejemplo 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()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CommentExists(Comment.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("../Index"));
        }