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

            _context.Attach(GlobalPlantList).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GlobalPlantListExists(GlobalPlantList.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> OnPost(int?id, string OrchardName, UserPlantList userPlantList)
        {
            this.OrchardName = OrchardName;
            var userId = _userManager.GetUserId(HttpContext.User);

            UserPlantList.UserID = userId;

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(UserPlantList).State = EntityState.Added;
            _context.UserPlantLists.Add(UserPlantList);

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserPlantListExists(UserPlantList.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            // await SaveOrchard();
            return(RedirectToPage("./Index", new { this.OrchardName }));
        }