Exemplo n.º 1
0
        public async Task <IActionResult> PutCodeShare([FromRoute] int id, [FromBody] CodeShare codeShare)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != codeShare.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> PostCodeShare([FromBody] CodeShare codeShare)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.CodeShare.Add(codeShare);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCodeShare", new { id = codeShare.Id }, codeShare));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            CodeShare = await _context.CodeShare.FirstOrDefaultAsync(m => m.Id == id);

            if (CodeShare == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Exemplo n.º 4
0
        public async Task<IActionResult> OnPostAsync(int? id)
        {
            if (id == null)
            {
                return NotFound();
            }

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

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

            return RedirectToPage("./Index");
        }