コード例 #1
0
        public async Task <IActionResult> PutCompany(int id, Company company)
        {
            if (id != company.CompanyId)
            {
                return(BadRequest());
            }

            _context.Entry(company).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CompanyExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #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(Contact).State = EntityState.Modified;

            // System.Diagnostics.Trace.WriteLine(Request.Headers["Referer"].ToString());

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ContactExists(Contact.ContactId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            // Get the Previous Page Url
            string prevPage = HttpContext.Session.GetString("PreviousUrl");

            if (!String.IsNullOrEmpty(prevPage))
            {
                System.Diagnostics.Trace.WriteLine(this.PreviousPage);
                return(Redirect(prevPage));
            }
            else
            {
                return(RedirectToPage("./Index"));
            }
        }
コード例 #3
0
ファイル: Create.cshtml.cs プロジェクト: CarloLinga/RazorCMS
        // 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.Contacts.Add(Contact);
            await _context.SaveChangesAsync();

            // Get the Previous Page Url
            string prevPage = HttpContext.Session.GetString("PreviousUrl");

            if (!String.IsNullOrEmpty(prevPage))
            {
                return(Redirect(prevPage));
            }
            else
            {
                return(RedirectToPage("./Index"));
            }
        }