// To protect from overposting attacks, 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(Currency).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CurrencyExists(Currency.CurrencyId)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, 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(CarsModel).State = EntityState.Modified; CarsModel.Year = CarsModel.Date.Year; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CarsModelExists(CarsModel.CarsModelId)) { ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator."); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { //if (!ModelState.IsValid) //{ // return Page(); //} var data = await _context.Cars.FindAsync(Cars.Id); _context.Attach(data).State = EntityState.Modified; try { data.Price = Cars.Price; data.PriceNaira = Cars.PriceNaira; await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CarExists(Cars.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, 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(Cars).State = EntityState.Modified; var ModelId = Cars.CarsModelId; var cid = Cars.Id; var ModelName = _context.CarsModel.FindAsync(ModelId).Result; Cars = _context.Cars.FindAsync(cid).Result; if (FileUpload == null && MultipleFileUpload.Count == 0) { Cars.DisplayFileName = Cars.DisplayFileName; Cars.FolderName = Cars.FolderName; Cars.ArrayFileName = Cars.ArrayFileName; Cars.ThumbFolderName = Cars.ThumbFolderName; //_context.Remove(Cars.ThumbFolderName).State = EntityState.Detached; //_context.Remove(Cars.FolderName).State = EntityState.Detached; //_context.Remove(Cars.ArrayFileName).State = EntityState.Detached; //_context.Remove(Cars.DisplayFileName).State = EntityState.Detached; } try // process properties or fields changes to database { Cars.ModelName = ModelName.Name; await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { ModelState.AddModelError("", "Unable to save changes.Try again, and if the problem persists, see your system administrator."); } return(RedirectToPage("./Index")); }