コード例 #1
0
        // GET: Students/Edit/5
        public ActionResult Edit(string id)
        {
            StudentVM s = studentAppService.GetVMById(id);

            return(View(s));
        }
コード例 #2
0
        public ActionResult Delete(StudentVM studentVM)
        {
            StudentRepository.Delete(studentVM.Student.StudentId);

            return(RedirectToAction("List"));
        }
コード例 #3
0
        public JsonResult GetStudentById(int studentId)
        {
            StudentVM student = studentManager.GetStudentWithDepartment(studentId);

            return(Json(student));
        }
コード例 #4
0
        public async Task <IActionResult> Add(StudentVM stud)
        {
            await _repository.AddItemAsync(stud);

            return(RedirectToAction("List"));
        }
コード例 #5
0
        //public ActionResult Index()
        public async Task <ActionResult> Profile()

        {
            string            Baseurl     = "https://localhost:44380/";
            List <Experience> experiences = new List <Experience>();

            List <Skill> skills = new List <Skill>();

            List <Project>      projects       = new List <Project>();
            List <Framework>    frameworkNames = new List <Framework>();
            List <Organization> organizations  = new List <Organization>();
            List <Domain>       domains        = new List <Domain>();

            StudentVM studentVM = new StudentVM();


            using (var client = new HttpClient())
            {
                int studentID = 6;
                //Passing service base url
                client.BaseAddress = new Uri(Baseurl);

                client.DefaultRequestHeaders.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));


                HttpResponseMessage Res1 = await client.GetAsync("api/studentProfile/GetExperienceByID/" + studentID);

                HttpResponseMessage Res2 = await client.GetAsync("api/studentProfile/GetProjectsByID/" + studentID);

                HttpResponseMessage Res3 = await client.GetAsync("api/studentProfile/GetSkillsByID/" + studentID);

                HttpResponseMessage Res4 = await client.GetAsync("api/studentProfile/GetAllFrameworkName");

                HttpResponseMessage Res5 = await client.GetAsync("api/studentProfile/GetOrganizations");

                HttpResponseMessage Res6 = await client.GetAsync("api/studentProfile/GetDomains");


                //Checking the response is successful or not which is sent using HttpClient
                if (Res1.IsSuccessStatusCode)
                {
                    //Storing the response details recieved from web api
                    var Response = Res1.Content.ReadAsStringAsync().Result;
                    experiences = JsonConvert.DeserializeObject <List <Experience> >(Response);

                    /*foreach (Experience e in experiences)
                     * {
                     *  e.StartDate = e.StartDate.Date;
                     *  e.EndDate = e.EndDate.Date;
                     * }*/
                }
                if (Res2.IsSuccessStatusCode)
                {
                    var Response = Res2.Content.ReadAsStringAsync().Result;
                    projects = JsonConvert.DeserializeObject <List <Project> >(Response);
                }
                if (Res3.IsSuccessStatusCode)
                {
                    var Response = Res3.Content.ReadAsStringAsync().Result;
                    skills = JsonConvert.DeserializeObject <List <Skill> >(Response);
                }
                if (Res4.IsSuccessStatusCode)
                {
                    var Response = Res4.Content.ReadAsStringAsync().Result;
                    frameworkNames = JsonConvert.DeserializeObject <List <Framework> >(Response);
                }
                if (Res5.IsSuccessStatusCode)
                {
                    var Response = Res5.Content.ReadAsStringAsync().Result;
                    organizations = JsonConvert.DeserializeObject <List <Organization> >(Response);
                }
                if (Res6.IsSuccessStatusCode)
                {
                    var Response = Res6.Content.ReadAsStringAsync().Result;
                    domains = JsonConvert.DeserializeObject <List <Domain> >(Response);
                }
                studentVM.StudentID         = studentID;
                studentVM.skills            = skills;
                studentVM.projects          = projects;
                studentVM.experiences       = experiences;
                studentVM.frameworkNames    = frameworkNames;
                studentVM.organizationNames = organizations;
                studentVM.domains           = domains;


                return(View(studentVM));
            }
            //return View();
        }
コード例 #6
0
        public ActionResult Search(StudentVM studentView, string Command)
        {
            //if Command Add then Redirect it to Add
            if (string.Equals(Command, "Add"))
            {
                return(RedirectToAction("Register"));
            }
            StudentVM  studView = null;
            StudentDTO student  = null;

            //Fetch the StandardSection List
            studentView.StandardSectionList = _uiddlRepo.getStandardSectionDropDown();

            if (studentView != null)
            {
                student = new StudentDTO();
                //studentView.UserDetails = new UserMasterDTO();
                student.UserDetails = new UserMasterDTO();
                // Search for FName LName and MName

                student.UserDetails.FName = studentView.UserDetails.FName;
                student.UserDetails.MName = studentView.UserDetails.MName;
                student.UserDetails.LName = studentView.UserDetails.LName;

                student.StandardSectionMap          = new StandardSectionMapDTO();
                student.StandardSectionMap.Standard = new StandardDTO();
                student.StandardSectionMap.Section  = new SectionDTO();

                // Search for Class

                student.StandardSectionMap.StandardSectionId = studentView.StandardSectionMap.StandardSectionId;

                // Search for Roll and Registration

                student.RollNumber         = studentView.RollNumber;
                student.RegistrationNumber = studentView.RegistrationNumber;

                StatusDTO <List <StudentDTO> > status = _studSvc.Select(student);

                if (status.ReturnObj != null && status.ReturnObj.Count > 0)
                {
                    studView             = new StudentVM();        // Instantiating Student View model
                    studView.studentList = new List <StudentVM>(); // instantiating list of Students

                    //Fetch the StandardSection List
                    studView.StandardSectionList = _uiddlRepo.getStandardSectionDropDown();

                    if (status.IsSuccess && !status.IsException)
                    {
                        //studView = new List<StudentVM>();

                        StudentVM searchItem = null;
                        foreach (StudentDTO stud in status.ReturnObj)
                        {
                            if (stud != null)
                            {
                                searchItem = new StudentVM(); // instantiating each student

                                searchItem.Active             = stud.Active;
                                searchItem.FatherContact      = stud.FatherContact;
                                searchItem.RegistrationNumber = stud.RegistrationNumber;
                                searchItem.RollNumber         = stud.RollNumber;

                                searchItem.UserDetails = new UserMasterDTO();
                                searchItem.UserDetails.UserMasterId = stud.UserDetails.UserMasterId;
                                searchItem.UserDetails.FName        = stud.UserDetails.FName;
                                searchItem.UserDetails.MName        = stud.UserDetails.MName;
                                searchItem.UserDetails.LName        = stud.UserDetails.LName;

                                searchItem.Name = searchItem.UserDetails.FName;
                                if (!string.IsNullOrEmpty(searchItem.UserDetails.MName))
                                {
                                    searchItem.Name = searchItem.Name + " " + searchItem.UserDetails.MName;
                                }

                                searchItem.Name = searchItem.Name + " " + searchItem.UserDetails.LName;

                                searchItem.StandardSectionMap          = new StandardSectionMapDTO();
                                searchItem.StandardSectionMap.Standard = new StandardDTO();
                                searchItem.StandardSectionMap.Section  = new SectionDTO();

                                searchItem.StandardSectionMap.Standard.StandardName = stud.StandardSectionMap.Standard.StandardName;
                                searchItem.StandardSectionMap.Section.SectionName   = stud.StandardSectionMap.Section.SectionName;

                                //Add into Student vIew Model List
                                studView.studentList.Add(searchItem);
                                studView.IsSearchSuccessful = true;
                            }
                        }
                    }
                }
                else
                {
                    studView = studentView;
                    studentView.IsSearchSuccessful = false;
                }
            }

            return(View(studView));
        }
コード例 #7
0
        public ActionResult AddStudent()
        {
            StudentVM svm = new StudentVM();

            return(View(svm));
        }
コード例 #8
0
 public void Post([FromBody] StudentVM student)
 {
     var requestData = student;
     //Save data to DB
 }
コード例 #9
0
        public bool CheckStudentExists(StudentVM studentVM)
        {
            Student student = Mapper.Map <Student>(studentVM);

            return(TheUnitOfWork.Student.CheckStudentExists(student));
        }
コード例 #10
0
        public ActionResult Details(int id)
        {
            Student student = stdManagementService.GetById(id); //courseservice.GetById(id);

            return(View(StudentVM.ToStudentVM(student)));
        }
コード例 #11
0
        public ActionResult AddStudent(StudentVM model, HttpPostedFileBase file)
        {
            if (!ModelState.IsValid)
            {
                using (Db db = new Db())
                {
                    model.Cohorts = new SelectList(db.Cohorts.ToList(), "Id", "Name");
                    return(View(model));
                }
            }

            using (Db db = new Db())
            {
                if (db.Student.Any(x => x.FirstName == model.FirstName))
                {
                    model.Cohorts = new SelectList(db.Cohorts.ToList(), "Id", "Name");
                    ModelState.AddModelError("", "Sorry! That student name is taken!");
                    return(View(model));
                }
            }

            int id;

            using (Db db = new Db())
            {
                StudentDTO student = new StudentDTO();

                student.FirstName = model.FirstName;
                student.LastName  = model.LastName;
                student.Root      = model.FirstName.Replace(" ", "-").ToLower();
                student.CohortId  = model.CohortId;

                CohortDTO catDTO = db.Cohorts.FirstOrDefault(x => x.Id == model.CohortId);
                student.CohortName = catDTO.Name;

                db.Student.Add(student);
                //db.SaveChanges();

                id = student.Id;
            }

            TempData["SM"] = "Successfully added a student!";

            #region Upload Image

            var originalDirectory = new DirectoryInfo(string.Format("{0}Images\\Uploads", Server.MapPath(@"\")));

            var pathString1 = Path.Combine(originalDirectory.ToString(), "Products");
            var pathString2 = Path.Combine(originalDirectory.ToString(), "Products\\" + id.ToString());
            var pathString3 = Path.Combine(originalDirectory.ToString(), "Products\\" + id.ToString() + "\\Thumbs");
            var pathString4 = Path.Combine(originalDirectory.ToString(), "Products\\" + id.ToString() + "\\Gallery");
            var pathString5 = Path.Combine(originalDirectory.ToString(), "Products\\" + id.ToString() + "\\Gallery\\Thumbs");

            if (!Directory.Exists(pathString1))
            {
                Directory.CreateDirectory(pathString1);
            }

            if (!Directory.Exists(pathString2))
            {
                Directory.CreateDirectory(pathString2);
            }

            if (!Directory.Exists(pathString3))
            {
                Directory.CreateDirectory(pathString3);
            }

            if (!Directory.Exists(pathString4))
            {
                Directory.CreateDirectory(pathString4);
            }

            if (!Directory.Exists(pathString5))
            {
                Directory.CreateDirectory(pathString5);
            }

            if (file != null && file.ContentLength > 0)
            {
                string ext = file.ContentType.ToLower();

                if (ext != "image/jpg" &&
                    ext != "image/jpeg" &&
                    ext != "image/pjpeg" &&
                    ext != "image/gif" &&
                    ext != "image/x-png" &&
                    ext != "image/png")
                {
                    using (Db db = new Db())
                    {
                        model.Cohorts = new SelectList(db.Cohorts.ToList(), "Id", "Name");
                        ModelState.AddModelError("", "ERROR: The image was not uploaded - wrong image extension.");
                        return(View(model));
                    }
                }

                string imageName = file.FileName;

                using (Db db = new Db())
                {
                    StudentDTO dto = db.Student.Find(id);
                    if (dto != null)
                    {
                        dto.ImageName = imageName;
                    }

                    db.SaveChanges();
                }

                var path  = string.Format("{0}\\{1}", pathString2, imageName);
                var path2 = string.Format("{0}\\{1}", pathString3, imageName);

                file.SaveAs(path);

                WebImage img = new WebImage(file.InputStream);
                img.Resize(200, 200);
                img.Save(path2);
            }

            #endregion

            return(RedirectToAction("AddStudent"));
        }
コード例 #12
0
        public ActionResult Index2()
        {
            StudentVM stu = new StudentVM();

            return(View(stu));
        }
コード例 #13
0
        public ActionResult PromoteToNewClass(StudentVM studentView, string Command)
        {
            int               StandardSectionId = 0;
            int               currentSerial     = 0;
            int               Serial            = 0;
            StudentVM         studView          = null;
            List <StudentDTO> studListPass      = null;

            if (Command != null)
            {
                // storing all data in studPass object and Passing it to PromoteToNewClass()
                studListPass = new List <StudentDTO>();

                if (string.Equals(Command, "Promotion Confirmed"))
                {
                    StatusDTO <List <StudentDTO> > batchStatus = _studSvc.PromoteToNewClass(null, Command, 0);

                    if (batchStatus.ReturnObj != null)
                    {
                        return(RedirectToAction("PromoteToNewClass"));
                    }
                }

                // To store StandardSectionId for Promote and Standard
                if (string.Equals(Command, "Promote"))
                {
                    StandardSectionId = (int)TempData.Peek("StandardSection");
                    //currentStandardId = StandardSectionId;
                }
                else if (string.Equals(Command, "Standard"))
                {
                    StandardSectionId           = studentView.StandardSectionMap.StandardSectionId;
                    TempData["StandardSection"] = StandardSectionId;
                }


                //For Storing exact string values instead of keys in database
                if (studentView != null && (string.Equals(Command, "Promote")))
                {
                    foreach (StudentVM studVM in studentView.studentList)
                    {
                        StudentDTO student = new StudentDTO();
                        student.StudentInfoId = studVM.StudentInfoId;

                        if (string.Equals(studVM.Status, "1"))
                        {
                            student.Status = "Promotion Confirmed";
                            student.NewStandardSectionId = studVM.NewStandardSectionId;
                        }
                        else if (string.Equals(studVM.Status, "2"))
                        {
                            student.Status = "Failed";
                            student.NewStandardSectionId = StandardSectionId;
                        }

                        studListPass.Add(student);
                    }
                }

                //Get Students for that Particular class or Promote Students to New Class
                StatusDTO <List <StudentDTO> > status = _studSvc.PromoteToNewClass(studListPass, Command, StandardSectionId);

                if ((status.ReturnObj != null))
                {
                    studView             = new StudentVM();        // Instantiating Student View model As a Parent Whole
                    studView.studentList = new List <StudentVM>(); // instantiating list of Students

                    //Binding the Standard Section Id which is returned from the database
                    studView.StandardSectionMap = new StandardSectionMapDTO();
                    studView.StandardSectionMap.StandardSectionId = StandardSectionId;

                    //Fetch the StandardSection List for Upper Dropdown
                    studView.StandardSectionList = _uiddlRepo.getStandardSectionDropDown();

                    //Fetch the Promotion Status List
                    if (string.Equals(Command, "Standard"))
                    {
                        studView.PromotionStatusList = _uiddlRepo.getPromotionStatusDropDown();
                    }

                    if (status.IsSuccess && !status.IsException)
                    {
                        StudentVM studentV = null; // for each student
                        foreach (StudentDTO stud in status.ReturnObj)
                        {
                            if (stud != null)
                            {
                                studentV = new StudentVM(); // instantiating each student

                                studentV.Active        = stud.Active;
                                studentV.RollNumber    = stud.RollNumber;
                                studentV.StudentInfoId = stud.StudentInfoId;

                                studentV.Status = stud.Status;
                                studentV.NewStandardSectionId = stud.NewStandardSectionId;


                                //Fetch the Next StandardSectionList w.r.t Current
                                if (string.Equals(Command, "Standard"))
                                {
                                    currentSerial = stud.StandardSectionMap.Serial;
                                }

                                //Fetch New Standard and Section if they are assigned
                                studentV.StandardSectionMap          = new StandardSectionMapDTO();
                                studentV.StandardSectionMap.Standard = new StandardDTO();
                                studentV.StandardSectionMap.Section  = new SectionDTO();

                                studentV.StandardSectionMap.Standard.StandardName = stud.StandardSectionMap.Standard.StandardName;
                                studentV.StandardSectionMap.Section.SectionName   = studentV.StandardSectionMap.Section.SectionName;

                                studentV.NewStandardSectionMap = stud.NewStandardSectionMap;


                                studentV.UserDetails = new UserMasterDTO();
                                studentV.UserDetails.UserMasterId = stud.UserDetails.UserMasterId;
                                studentV.UserDetails.FName        = stud.UserDetails.FName;
                                studentV.UserDetails.MName        = stud.UserDetails.MName;
                                studentV.UserDetails.LName        = stud.UserDetails.LName;

                                studentV.Name = studentV.UserDetails.FName;
                                if (!string.IsNullOrEmpty(studentV.UserDetails.MName))
                                {
                                    studentV.Name = studentV.Name + " " + studentV.UserDetails.MName;
                                }

                                studentV.Name = studentV.Name + " " + studentV.UserDetails.LName;

                                //Add Into Student View Model List
                                studView.studentList.Add(studentV);
                                studView.IsSearchSuccessful = true;

                                if (!string.IsNullOrEmpty(studentV.Status))
                                {
                                    studView.IsCommandPromote = true;
                                }
                            }
                        }
                    }
                }
            }
            if (string.Equals(Command, "Standard"))
            {
                studView.NextStandardSectionList = _uiddlRepo.getNextStandardSectionDropDown(currentSerial);
            }
            return(View(studView));
        }
コード例 #14
0
        public ActionResult StudentProfile()
        {
            if (!string.IsNullOrEmpty(ApplicationSession.Current.UserID))
            {
                StudentVM studObj = new StudentVM();
                try
                {
                    using (var _db = new SchoolMSEntities())
                    {
                        studObj.TimeZoneInfos = TimeZoneInfo.GetSystemTimeZones()
                                                .Select(t => new
                                                        SelectListItem()
                        {
                            Text  = t.DisplayName,
                            Value = t.Id
                        }).ToList();

                        studObj.GradeList = _db.SchoolGrades.ToList()
                                            .Select(g => new SelectListItem()
                        {
                            Text  = g.Grade,
                            Value = g.Id.ToString()
                        }).ToList();

                        var student = _db.Students.Find(Guid.Parse(ApplicationSession.Current.UserID));

                        if (student != null)
                        {
                            studObj.BirthDate = student.BirthDate;

                            if (studObj.BirthDate != null)
                            {
                                DateTime dtBirth = Convert.ToDateTime(student.BirthDate);
                                studObj.BirthDateOnly  = dtBirth.Day;
                                studObj.BirthMonthOnly = dtBirth.Month;
                                studObj.BirthYearOnly  = dtBirth.Year;
                            }
                            else
                            {
                                DateTime dt = new DateTime();
                                dt = DateTime.Today;
                                studObj.BirthYearOnly  = dt.Year - 60;
                                studObj.BirthMonthOnly = dt.Month;
                                studObj.BirthDateOnly  = dt.Day;
                            }

                            studObj.Email             = student.Email;
                            studObj.Facetime          = student.Facetime;
                            studObj.FromCountry       = student.FromCountry;
                            studObj.FromState         = student.FromState;
                            studObj.Gender            = student.Gender;
                            studObj.GoogleHangout     = student.GoogleHangout;
                            studObj.Id                = student.Id;
                            studObj.LivingCountry     = student.LivingCountry;
                            studObj.LivingState       = student.LivingState;
                            studObj.Name              = student.Name;
                            studObj.NativeLanguage    = student.NativeLanguage;
                            studObj.ProfilePhoto      = student.ProfilePhoto;
                            studObj.QQ                = student.QQ;
                            studObj.SchoolGrade       = student.SchoolGrade;
                            studObj.Skype             = student.Skype;
                            studObj.TimeZone          = student.TimeZone;
                            studObj.Webchat           = student.Webchat;
                            studObj.SchoolName        = student.SchoolName;
                            studObj.ShortIntroduction = student.ShortIntroduction;
                            studObj.LongIntroduction  = student.LongIntroduction;
                            studObj.LookingFor        = student.LookingFor;

                            var StudentSubjects = _db.StudentSubjects.Where(s => s.StudentId == studObj.Id).ToList();

                            foreach (var item in StudentSubjects)
                            {
                                var SubjectList = _db.SchoolSubjects.Where(s => s.GradeId == item.SchoolGradeId).ToList().Select(s => new SelectListItem()
                                {
                                    Text  = s.Subject,
                                    Value = s.Id
                                }).ToList();

                                studObj.StudentSubjectList.Add(new StudentSchoolSubjects()
                                {
                                    GradeId     = item.SchoolGradeId,
                                    SubjectId   = item.SchoolSubjectId,
                                    IsLearning  = item.IsLearning,
                                    IsPrimary   = item.IsPrimary,
                                    SubjectList = SubjectList
                                });
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    return(RedirectToAction("Home", "Dashboard"));
                }
                return(View(studObj));
            }
            else
            {
                return(RedirectToAction("Home", "Dashboard"));
            }
            //return View();
        }
コード例 #15
0
        public ActionResult EditStudent(int id)
        {
            StudentVM svm = BusinessLayer.BusinessStudent.getStudentDetails(id);

            return(PartialView("_EditStudent", svm));
        }
コード例 #16
0
 public ActionResult EditAddress(StudentVM studentVM)
 {
     StudentRepository.SaveAddress(studentVM.Student.StudentId, studentVM.Student.Address);
     return(RedirectToAction("List"));
 }
コード例 #17
0
 public void Setup()
 {
     student  = new StudentAppServices();
     student2 = new StudentVM();
 }
コード例 #18
0
        public JsonResult <object> UpdateUserDetail([FromBody] JObject json)
        {
            StudentVM re  = JsonConvert.DeserializeObject <StudentVM>(json.ToString());
            var       obj = new object();
            Dictionary <string, object> dic = new Dictionary <string, object>();
            string Image1    = re.ProfilePic;
            string Image2    = re.Document1;
            string Image3    = re.Document2;
            string SavePath1 = "";
            string SavePath2 = "";
            string SavePath3 = "";

            try
            {
                if (!string.IsNullOrEmpty(Image1))
                {
                    var postedFile = Image1;
                    if (!Directory.Exists(HttpContext.Current.Server.MapPath("~/Document/ProfilePic/")))
                    {
                        Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~/Document/ProfilePic/"));
                    }
                    string ImagePath1 = HttpContext.Current.Server.MapPath("~/Document/ProfilePic/") + re.FirstName + re.LastName + ".jpg";
                    SavePath1 = "/Document/ProfilePic/" + re.FirstName + re.LastName + ".jpg";
                    if (File.Exists(ImagePath1))
                    {
                        File.Delete(ImagePath1);
                    }
                    byte[] Image1D = Convert.FromBase64String(Image1.ToString());

                    Stream stmImage1D   = new MemoryStream(Image1D);
                    Bitmap originalBMP1 = new Bitmap(stmImage1D);
                    originalBMP1.Save(ImagePath1);
                }
                if (!string.IsNullOrEmpty(Image2))
                {
                    var postedFile = Image2;
                    if (!Directory.Exists(HttpContext.Current.Server.MapPath("~/Document/Documents/")))
                    {
                        Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~/Document/Documents/"));
                    }
                    string ImagePath2 = HttpContext.Current.Server.MapPath("~/Document/Documents/") + re.FirstName + re.LastName + "Doc1.jpg";
                    SavePath2 = "/Document/Documents/" + re.FirstName + re.LastName + "Doc1.jpg";
                    if (File.Exists(ImagePath2))
                    {
                        File.Delete(ImagePath2);
                    }
                    byte[] Image2D = Convert.FromBase64String(Image2.ToString());

                    Stream stmImage2D   = new MemoryStream(Image2D);
                    Bitmap originalBMP2 = new Bitmap(stmImage2D);
                    originalBMP2.Save(ImagePath2);
                }
                if (!string.IsNullOrEmpty(Image3))
                {
                    var postedFile = Image3;
                    if (!Directory.Exists(HttpContext.Current.Server.MapPath("~/Document/Documents/")))
                    {
                        Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~/Document/Documents/"));
                    }
                    string ImagePath3 = HttpContext.Current.Server.MapPath("~/Document/Documents/") + re.FirstName + re.LastName + "Doc2.jpg";
                    SavePath3 = "/Document/Documents/" + re.FirstName + re.LastName + "Doc2.jpg";
                    if (File.Exists(ImagePath3))
                    {
                        File.Delete(ImagePath3);
                    }
                    byte[] Image3D      = Convert.FromBase64String(Image3.ToString());
                    Stream stmImage3D   = new MemoryStream(Image3D);
                    Bitmap originalBMP3 = new Bitmap(stmImage3D);
                    originalBMP3.Save(ImagePath3);
                }

                using (StudentsEntities context = new StudentsEntities())
                {
                    var result = context.StudentUpdate(re.StudentId, re.FirstName, re.LastName, re.DOB, re.PhoneNo, re.Address, re.BloodGroup, SavePath1, re.FatherName, re.category, re.MainSubject, SavePath2, SavePath3, re.Password, re.Obtional1, re.Obtional2, re.Obtional3, re.Obtional4, re.Role, Convert.ToBoolean(0), re.SubjectId, re.BloodGroupId);
                    dic.Add("Status", "1");
                    dic.Add("Message", "Success");
                }
            }
            catch (Exception E)
            {
                dic.Add("Message", E.Message);
                dic.Add("Status", "0");
            }
            obj = dic;
            return(Json(obj));
        }
コード例 #19
0
        public ActionResult EditStudent(StudentVM studentVM)
        {
            studentVM.Student.Courses = new List <Course>();


            foreach (var id in studentVM.SelectedCourseIds)
            {
                studentVM.Student.Courses.Add(CourseRepository.Get(id));
            }

            studentVM.Student.Major = MajorRepository.Get(studentVM.Student.Major.MajorId);


            var student = StudentRepository.Get(studentVM.Student.StudentId);


            if (studentVM.Student.Address.Street1 != null)
            {
                student.Address         = new Address();
                student.Address.Street1 = studentVM.Student.Address.Street1;
            }


            if (studentVM.Student.Address.Street2 != null)
            {
                student.Address.Street2 = studentVM.Student.Address.Street2;

                studentVM.Student.Address.Street2 = "";
            }

            else
            {
                studentVM.Student.Address.Street2 = "";
            }



            if (studentVM.Student.Address.City != null)
            {
                student.Address.City = studentVM.Student.Address.City;
            }


            if (studentVM.Student.Address.State.StateAbbreviation != null)
            {
                student.Address.State = new State();
                student.Address.State.StateAbbreviation = studentVM.Student.Address.State.StateAbbreviation;
            }


            if (studentVM.Student.Address.PostalCode != null)
            {
                student.Address.PostalCode = studentVM.Student.Address.PostalCode;
            }



            if (ModelState.IsValid)
            {
                StudentRepository.Edit(studentVM.Student);

                return(RedirectToAction("List"));
            }
            else
            {
                studentVM.SetMajorItems(MajorRepository.GetAll());

                return(View(studentVM));//
            }
        }
コード例 #20
0
        public IActionResult Edit(StudentVM editStudent)
        {
            var student = _studentRepository.EditStudent(editStudent.Student);

            return(RedirectToAction(nameof(Index)));
        }
コード例 #21
0
        public ActionResult Search()
        {
            StatusDTO <List <StudentDTO> > status = _studSvc.Select(null);
            StudentVM studView = null;

            if (status.ReturnObj != null && status.ReturnObj.Count > 0)
            {
                studView             = new StudentVM();        // Instantiating Student View model
                studView.studentList = new List <StudentVM>(); // instantiating list of Students

                //Fetch the StandardSection List
                studView.StandardSectionList = _uiddlRepo.getStandardSectionDropDown();

                if (status.IsSuccess && !status.IsException)
                {
                    //studView = new List<StudentVM>();

                    StudentVM searchItem = null;
                    foreach (StudentDTO student in status.ReturnObj)
                    {
                        if (student != null)
                        {
                            searchItem = new StudentVM(); // instantiating each student

                            searchItem.Active             = student.Active;
                            searchItem.FatherContact      = student.FatherContact;
                            searchItem.RegistrationNumber = student.RegistrationNumber;
                            searchItem.RollNumber         = student.RollNumber;


                            searchItem.UserDetails = new UserMasterDTO();
                            searchItem.UserDetails.UserMasterId = student.UserDetails.UserMasterId;
                            searchItem.UserDetails.FName        = student.UserDetails.FName;
                            searchItem.UserDetails.MName        = student.UserDetails.MName;
                            searchItem.UserDetails.LName        = student.UserDetails.LName;

                            searchItem.Name = student.UserDetails.FName;
                            if (!string.IsNullOrEmpty(student.UserDetails.FName))
                            {
                                searchItem.Name = searchItem.Name + " " + student.UserDetails.MName;
                            }

                            searchItem.Name = searchItem.Name + " " + searchItem.UserDetails.LName;


                            searchItem.StandardSectionMap          = new StandardSectionMapDTO();
                            searchItem.StandardSectionMap.Standard = new StandardDTO();
                            searchItem.StandardSectionMap.Section  = new SectionDTO();

                            searchItem.StandardSectionMap.Standard.StandardName = student.StandardSectionMap.Standard.StandardName;
                            searchItem.StandardSectionMap.Section.SectionName   = student.StandardSectionMap.Section.SectionName;

                            //Add into Student vIew Model List
                            studView.studentList.Add(searchItem);
                            studView.IsSearchSuccessful = true;
                        }
                    }
                }
                if (status.IsException)
                {
                    throw new Exception(status.ExceptionMessage);
                }
            }
            else
            {
                studView = new StudentVM();
                //Fetch the StandardSection List
                studView.StandardSectionList     = _uiddlRepo.getStandardSectionDropDown();
                studView.IsSearchSuccessful      = true;
                studView.MsgColor                = "green";
                studView.SuccessOrFailureMessage = "Please Select atleast 1 Search Criteria";
            }

            return(View(studView));
        }