public async Task <IActionResult> Edit(int id, BLL.App.DTO.Person person) { if (id != person.Id) { return(NotFound()); } // check for the ownership - is this Person record really belonging to logged in user. if (!await _bll.Persons.BelongsToUserAsync(id, User.GetUserId())) { return(NotFound()); } person.AppUserId = User.GetUserId(); if (ModelState.IsValid) { _bll.Persons.Update(person); await _bll.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(person)); }
public async Task <IActionResult> Create([Bind("FirstName,LastName,Id")] BLL.App.DTO.Person person) { person.AppUserId = User.GetUserId(); if (ModelState.IsValid) { _bll.Persons.Add(person); await _bll.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(person)); }