public async Task <IActionResult> Add([Bind("")] PersonAddModel personAddModel) { if (!ModelState.IsValid) { ModelState.AddModelError(string.Empty, "Your information is don't valid"); return(View("Add")); } personAddModel.Person.IsPersonActive = true; // IsActivePerson'a özel güzel bir süreç oluştur. try { var result = await _schoolDataDbContext.AddAsync(personAddModel.Person); await _schoolDataDbContext.SaveChangesAsync(); return(RedirectToAction("List")); } catch (DbUpdateException error) { ModelState.AddModelError(string.Empty, "Unable to save changes" + "\n Message:" + error.Message.ToString() + "Inner Exception:" + error.InnerException.ToString()); } return(View(personAddModel)); }
public async Task <IActionResult> Add([Bind("Name")] LessonManagerModel lessonAddModel) { if (!ModelState.IsValid) { ModelState.AddModelError(string.Empty, "Your information is don't valid"); return(View("Add")); } try { var result = await _schoolDataDbContext.AddAsync(lessonAddModel.Lesson); await _schoolDataDbContext.SaveChangesAsync(); return(RedirectToAction("List")); } catch (DbUpdateException error) { ModelState.AddModelError(string.Empty, "Unable to save changes" + "\n Message:" + error.Message.ToString() + "Inner Exception:" + error.InnerException.ToString()); } return(View(lessonAddModel)); }