public async Task <ActionResult> Create([Bind(Include = "Id,Name,Type,Email,MobileNo")] Teacher teacher) { ViewBag.Types = new List <SelectListItem>() { new SelectListItem() { Value = "1", Text = "Tutor" }, new SelectListItem() { Value = "2", Text = "Lecture" } }; bool status = false; string message = string.Empty; if (ModelState.IsValid) { try { status = await _logic.InsertUpdateTeacher(teacher); } catch (SqlException ex) { message = ex.Message; } catch (Exception) { message = "Unexpected error was found"; } } if (status) { return(RedirectToAction("Index")); } else { ViewBag.Message = message; return(View(teacher)); } }