public async Task <ActionResult> Create([Bind(Include = "Id,Name,RollNumber,Email,AcademicYear,EnrollDate")] SAMS.Models.Student student)
        {
            bool   status  = false;
            string message = string.Empty;

            if (ModelState.IsValid)
            {
                try
                {
                    status = await _logic.InsertUpdateStudent(student);
                }
                catch (SqlException ex)
                {
                    message = ex.Message;
                }
                catch (Exception)
                {
                    message = "Unexpected error was found";
                }
            }
            if (status)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                ViewBag.Message = message;
                return(View(student));
            }
        }
        // GET: /Student/Edit/5Inde
        public async Task <ActionResult> Edit(int id)
        {
            // Student student = db.Students.Find(id);
            SAMS.Models.Student student = await _logic.GetStudent(id);

            if (student == null)
            {
                return(HttpNotFound());
            }
            return(View(student));
        }
        public async Task <bool> InsertUpdateStudent(SAMS.Models.Student student)
        {
            string          query      = "SpInsertUpdateStudent";
            List <SqlParam> collection = new List <SqlParam>()
            {
                new SqlParam("@Id", SqlDbType.Int, student.Id),
                new SqlParam("@Name", SqlDbType.NVarChar, student.Name),
                new SqlParam("@RollNumber", SqlDbType.NVarChar, student.RollNumber),
                new SqlParam("@Email", SqlDbType.NVarChar, student.Email),
                new SqlParam("@AcademicYear", SqlDbType.NVarChar, student.AcademicYear),
                new SqlParam("@EnrollDate", SqlDbType.Date, student.EnrollDate),
            };

            return(await _dao.ExecuteNonQueryAsync(query, collection, CommandType.StoredProcedure));
        }
 public async Task <bool> InsertUpdateStudent(SAMS.Models.Student student)
 {
     return(await _repo.InsertUpdateStudent(student));
 }