예제 #1
0
        public async Task <IActionResult> OnPostAsync(string OrchardName)
        {
            UserPlantList userPlantList = new UserPlantList();
            var           userId        = _userManager.GetUserId(HttpContext.User);

            userPlantList.UserID        = userId;
            userPlantList.OrchardName   = OrchardName;
            userPlantList.FruitVariety  = GlobalPlantList.FruitVariety;
            userPlantList.PlantName     = GlobalPlantList.Name;
            userPlantList.Origin        = GlobalPlantList.Origin;
            userPlantList.YearDeveloped = GlobalPlantList.YearDeveloped;
            userPlantList.Comments      = GlobalPlantList.Comments;
            userPlantList.Use           = GlobalPlantList.Use;

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

            this.OrchardName = OrchardName;

            _context.UserPlantLists.Add(userPlantList);
            await _context.SaveChangesAsync();


            // _context.GlobalPlantLists.Add(GlobalPlantList);
            // await _context.SaveChangesAsync();

            return(RedirectToPage("/UserPlants/Index"));
        }
예제 #2
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"));
        }
예제 #3
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 }));
        }
예제 #4
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            GlobalPlantList = await _context.GlobalPlantLists.FindAsync(id);

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

            return(RedirectToPage("./Index"));
        }
예제 #5
0
        public async Task <IActionResult> OnPostAsync()
        {
            var userId = _userManager.GetUserId(HttpContext.User);

            Orchard.UserID = userId;

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


            _context.Orchards.Add(Orchard);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
예제 #6
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Orchard = await _context.Orchards.FindAsync(id);

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

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