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")); }
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 })); }
public IActionResult OnGetAsync(int?id, string OrchardName) { //UserPlantList = new UserPlantList(); this.OrchardName = OrchardName; var userId = _userManager.GetUserId(HttpContext.User); this.UserPlantList = new UserPlantList(); return(Page()); }
public async Task <IActionResult> OnGetAsync(int?id, string OrchardName) { if (id == null) { return(NotFound()); } this.OrchardName = OrchardName; UserPlantList = await _context.UserPlantLists.SingleOrDefaultAsync(m => m.ID == id); if (UserPlantList == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } UserPlantList = await _context.UserPlantList.SingleOrDefaultAsync(m => m.ID == id); if (UserPlantList == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } UserPlantList = await _context.UserPlantList.FindAsync(id); if (UserPlantList != null) { _context.UserPlantList.Remove(UserPlantList); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } globalPlantList = await _context.GlobalPlantList.SingleOrDefaultAsync(m => m.ID == id); userPlantList.FruitVariety = globalPlantList.FruitVariety; userPlantList.Name = globalPlantList.Name; userPlantList.Origin = globalPlantList.Origin; userPlantList.YearDeveloped = globalPlantList.YearDeveloped; userPlantList.Comments = globalPlantList.Comments; userPlantList.Use = globalPlantList.Use; UserPlantList = userPlantList; if (userPlantList == null) { return(NotFound()); } return(Page()); }
// GET: OrchardName public ActionResult Index(int?id, UserPlantList userPlantList, string OrchardName) { return(View()); }