コード例 #1
0
        // 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.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
コード例 #2
0
ファイル: Create.cshtml.cs プロジェクト: Paddy625/PP_LAB_4
        // To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.currency.Add(currency);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
コード例 #3
0
ファイル: Delete.cshtml.cs プロジェクト: Paddy625/PP_LAB_4
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            currency = await _context.currency.FindAsync(id);

            if (currency != null)
            {
                _context.currency.Remove(currency);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
コード例 #4
0
        // To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }


            var curre = (from s in _context.currency
                         where s.record_date == cur.record_date && s.name == cur.name
                         select s).ToList <currency>();

            if (curre.Count() == 0) //jak nie ma w bazie
            {
                await cur.load(cur.record_date);

                cur.exchange = cur.rates[cur.name];
                _context.currency.Add(cur);
                await _context.SaveChangesAsync();
            }

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