Ejemplo n.º 1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            Segment.Owner = Globals.CURRENT_USER;
            _context.Attach(Segment).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SegmentExists(Segment.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            if (Globals.FROM_BOOK_ID == null)
            {
                return(RedirectToPage("./Index"));
            }
            else
            {
                return(Redirect("../Books/Details?id=" + Globals.FROM_BOOK_ID));
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            Book.Owner                  = Globals.CURRENT_USER;
            Book.SegmentIdsString       = string.Join(",", SegmentOptions.OrderBy(item => item.Order).Where(item => item.Checked).Select(item => item.Id));
            _context.Attach(Book).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BookExists(Book.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

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