public async Task <ActionResult> Upload(HttpPostedFileBase upload, int id)
        {
            try
            {
                var getstudent = await _studentInfoService.Get(id);

                if (getstudent != null)
                {
                    if (getstudent.ImageId != 0)
                    {
                        await _imageService.Delete(getstudent.ImageId);
                    }
                    var imgId = await _imageService.Create(upload);

                    await _studentInfoService.UpdateImageId(getstudent.Id, imgId);

                    TempData["success"] = "Update Successful.";
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                TempData["error"] = "Update Unsuccessful." + ex;
            }
            return(View());
        }
        public async Task <ActionResult> NewStudent(RegisterViewModel model, HttpPostedFileBase upload, int packageId)
        {
            var ee = "";

            if (ModelState.IsValid)
            {
                try
                {
                    string succed;

                    succed = await _userService.NewStudent(model);

                    if (succed == "true")
                    {
                        var Imageid = await _imageService.Create(upload);

                        var user = await UserManager.FindByNameAsync(model.Username);

                        // var user = await _userService.GetUserByUserEmail(model.Email);
                        var student = await _studentService.GetStudentByUserId(user.Id);

                        //profile pic upload
                        await _studentService.UpdateImageId(student.Id, Imageid);

                        //enrolment
                        //await _enrollmentService.EnrollStudent(classId, student.Id);
                        //var classLevel = await _classlevelService.Get(classId);
                        TempData["success"] = "Student with username <i> " + model.Username + "</i> Added Successfully";
                        return(RedirectToAction("NewStudent"));
                    }
                    else
                    {
                        TempData["error1"] = succed;
                    }
                }
                catch (Exception e)
                {
                    ee = e.ToString();
                }
            }
            var allErrors = ModelState.Values.SelectMany(v => v.Errors);

            TempData["error"] = "Creation of new student not successful" + ee;
            //var classlevel = await _classlevelService.ClassLevelList();
            ViewBag.PackageId     = new SelectList(db.Packages, "Id", "PackageName");
            ViewBag.StateOfOrigin = new SelectList(db.States.OrderBy(x => x.StateName), "StateName", "StateName", model.StateOfOrigin);
            return(View(model));
        }