public async Task <IActionResult> Create([Bind("ID,FindingCategory,Material,Description,Color,Length_CM,Price_Point,Brand")] Finding finding)
        {
            if (ModelState.IsValid)
            {
                _context.Add(finding);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(finding));
        }
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            _context.Finding.Add(Finding);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Esempio n. 3
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            Finding = await _context.Finding.FindAsync(id);

            if (Finding != null)
            {
                _context.Finding.Remove(Finding);
                await _context.SaveChangesAsync();
            }
            return(RedirectToPage("./Index"));
        }
 public async Task <IActionResult> OnPostAsync()
 {
     if (!ModelState.IsValid)
     {
         return(Page());
     }
     _context.Attach(Finding).State = EntityState.Modified;
     try{
         await _context.SaveChangesAsync();
     }catch (DbUpdateConcurrencyException) {
         if (!FindingExists(Finding.ID))
         {
             return(NotFound());
         }
         else
         {
             throw;
         }
     }
     return(RedirectToPage("./Index"));
 }