コード例 #1
0
        public async Task <int> EditQualification(TeacherQualification models)
        {
            db.Entry(models).State = EntityState.Modified;
            await db.SaveChangesAsync();

            return(models.Id);
        }
コード例 #2
0
        public async Task <int> CreateQualification(TeacherQualification model)
        {
            var userid    = HttpContext.Current.User.Identity.GetUserId();
            var teacherid = await db.TeacherProfiles.FirstOrDefaultAsync(x => x.UserId == userid);

            model.UserId           = userid;
            model.TeacherProfileID = teacherid.Id;
            db.TeacherQualifications.Add(model);
            await db.SaveChangesAsync();

            return(model.Id);
        }
コード例 #3
0
        public async Task <ActionResult> AddQualification(TeacherQualification model)
        {
            if (ModelState.IsValid)
            {
                var id = await _teacherProfileService.CreateQualification(model);

                TempData["success"] = "Qualification Added Successfully";
                return(RedirectToAction("Index", "Panel", new { area = "Teacher" }));
            }
            TempData["error"] = "Unable to add Qualification";
            return(View(model));
        }
コード例 #4
0
 public bool AddTeacherQualification(QualificationParam model)
 {
     try
     {
         UnitOfWork           uow    = new UnitOfWork();
         var                  userId = Session["UserId"].ToString();
         TeacherQualification td     = new TeacherQualification();
         td.DegreeTitle   = model.DegreeTitle;
         td.InstituteName = model.InstituteName;
         td.TeacherID     = userId;
         td.YearPassed    = model.YearPassed;
         td.CreationDate  = DateTime.Now;
         td.Status        = 1;
         uow.TeacherQualifications.Insert(td);
         uow.Save();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
コード例 #5
0
        public async Task <IActionResult> UpdateTeacher(TeacherViewModel tr)

        {
            Teacher tchr = new Teacher()
            {
                TeacherId          = tr.TcridVM,
                TeacherName        = tr.TcrnameVM,
                TeacherBG          = tr.TcrbgVM,
                TeacherEmail       = tr.TcremailVM,
                TeacherCAddress    = tr.TcrcaddrssVM,
                TeacherPAddress    = tr.TcrpaddrssVM,
                TeacherDOB         = tr.TcrdobVM,
                TeacherGender      = tr.TcrgenderVM,
                TeacherNationality = tr.TcrnationVM,
                TeacherPhoneNo     = tr.TcrphoneVM,
                TeacherJD          = tr.TcrjdVM,
                TeacherPhoto       = tr.TcrphotoVM,
                TeacherDesignation = tr.TcrdesigVM
            };

            _context.Teacher.Update(tchr);
            await _context.SaveChangesAsync();


            ///Save the Document Information to the Database

            TeacherDocSubmitted doc = new TeacherDocSubmitted()
            {
                TeacherId       = tr.TcridVM,
                SL              = tr.DocSLVM,
                SSCCertificate  = tr.TcrdocsubhsccrtfctVM,
                SSCMarksheet    = tr.TcrdocsubsscmarkVM,
                HSCCertificate  = tr.TcrdocsubhsccrtfctVM,
                HSCMarksheet    = tr.TcrdocsubhscmarkVM,
                HonsCertificate = tr.TcrdocsubhonscrtfctVM,
                HonsMarksheet   = tr.TcrdocsubhonsmarkVM
            };

            _context.TeacherDocSubmitted.Update(doc);
            await _context.SaveChangesAsync();

            TeacherQualification tq = new TeacherQualification()
            {
                SL            = tr.QlSLVM,
                TeacherId     = tr.TcridVM,
                SSCYear       = tr.TcrqsscyearVM,
                SSCGrade      = tr.TcrqsscgradeVM,
                SSCInstitute  = tr.TcrqsscinsVM,
                HSCYear       = tr.TcrqhscyearVM,
                HSCGrade      = tr.TcrqhscgradeVM,
                HSCInstitute  = tr.TcrqhscinsVM,
                HonsYear      = tr.TcrqhonsyearVM,
                HonsGrade     = tr.TcrqhonsgradeVM,
                HonsInstitute = tr.TcrqhonsinsVM
            };

            _context.TeacherQualification.Update(tq);
            await _context.SaveChangesAsync();



            ///Clear the model state

            ModelState.Clear();

            return(View());
        }
コード例 #6
0
        public async Task <IActionResult> NewTeacher(TeacherViewModel tr)
        {
            Teacher tchr = new Teacher()
            {
                TeacherId          = 0,
                TeacherName        = tr.TcrnameVM,
                TeacherBG          = tr.TcrbgVM,
                TeacherEmail       = tr.TcremailVM,
                TeacherCAddress    = tr.TcrcaddrssVM,
                TeacherPAddress    = tr.TcrpaddrssVM,
                TeacherDOB         = tr.TcrdobVM,
                TeacherGender      = tr.TcrgenderVM,
                TeacherNationality = tr.TcrnationVM,
                TeacherPhoneNo     = tr.TcrphoneVM,
                TeacherJD          = DateTime.Now.Date,
                TeacherPhoto       = tr.TcrphotoVM,
                TeacherDesignation = tr.TcrdesigVM
            };

            _context.Teacher.Add(tchr);
            await _context.SaveChangesAsync();

            ///Get the id of teacher
            var TeacherId = tchr.TeacherId;
            //Teacher email
            var TeacherEmail = tchr.TeacherEmail;
            // Create random password
            PasswordCreator ps = new PasswordCreator();
            //Create login
            Login lg = new Login()
            {
                SL               = 0,
                Username         = TeacherEmail,
                Password         = ps.RandomPassword(),
                FirstLoginStatus = false,
                ActiveStatus     = true,
                RoleId           = 2,
                DistinguishId    = TeacherId
            };

            lg.CurrentPassword = lg.Password;
            _context.Login.Add(lg);
            await _context.SaveChangesAsync();

            ///Save the Document Information to the Database

            TeacherDocSubmitted doc = new TeacherDocSubmitted()
            {
                TeacherId       = TeacherId,
                SL              = 0,
                SSCCertificate  = tr.TcrdocsubhsccrtfctVM,
                SSCMarksheet    = tr.TcrdocsubsscmarkVM,
                HSCCertificate  = tr.TcrdocsubhsccrtfctVM,
                HSCMarksheet    = tr.TcrdocsubhscmarkVM,
                HonsCertificate = tr.TcrdocsubhonscrtfctVM,
                HonsMarksheet   = tr.TcrdocsubhonsmarkVM
            };

            await _context.TeacherDocSubmitted.AddAsync(doc);

            await _context.SaveChangesAsync();

            TeacherQualification tq = new TeacherQualification()
            {
                SL            = 0,
                TeacherId     = TeacherId,
                SSCYear       = tr.TcrqsscyearVM,
                SSCGrade      = tr.TcrqsscgradeVM,
                SSCInstitute  = tr.TcrqsscinsVM,
                HSCYear       = tr.TcrqhscyearVM,
                HSCGrade      = tr.TcrqhscgradeVM,
                HSCInstitute  = tr.TcrqhscinsVM,
                HonsYear      = tr.TcrqhonsyearVM,
                HonsGrade     = tr.TcrqhonsgradeVM,
                HonsInstitute = tr.TcrqhonsinsVM
            };
            await _context.TeacherQualification.AddAsync(tq);

            await _context.SaveChangesAsync();



            ///Clear the model state

            ModelState.Clear();

            return(View());
        }
コード例 #7
0
        public async Task <IActionResult> UpdateTeacher(TeacherVm tr, IFormFile image)
        {
            if (ModelState.IsValid)
            {
                Teacher tchr = new Teacher()
                {
                    TeacherId          = tr.TcridVM,
                    TeacherName        = tr.TcrnameVM,
                    TeacherBG          = tr.TcrbgVM,
                    TeacherEmail       = tr.TcremailVM,
                    TeacherCAddress    = tr.TcrcaddrssVM,
                    TeacherPAddress    = tr.TcrpaddrssVM,
                    TeacherDOB         = tr.TcrdobVM,
                    TeacherGender      = tr.TcrgenderVM,
                    TeacherNationality = tr.TcrnationVM,
                    TeacherPhoneNo     = tr.TcrphoneVM,
                    TeacherJD          = tr.TcrjdVM,
                    TeacherPhoto       = tr.TcrphotoVM,
                    TeacherDesignation = tr.TcrdesigVM
                };

                //if (image == null)
                //{
                //    if (tr.TcrphotoVM != null)
                //    {
                //        var path = Path.Combine(_imagepath.WebRootPath + "/images");
                //        string filepath = Path.Combine(path, tr.TcrphotoVM);
                //        System.IO.File.Delete(filepath);
                //        tchr.TeacherPhoto = null;
                //    }

                //}
                string un = null;
                if (image != null)
                {
                    if (tr.TcrphotoVM != null)
                    {
                        /// Delete Existing Image
                        var    path     = Path.Combine(_imagepath.WebRootPath + "/images");
                        string filepath = Path.Combine(path, tr.TcrphotoVM);
                        if (System.IO.File.Exists(filepath))
                        {
                            System.IO.File.Delete(filepath);
                        }

                        tchr.TeacherPhoto = null;
                        path     = null;
                        un       = null;
                        filepath = null;

                        ///Update Image
                        path     = Path.Combine(_imagepath.WebRootPath + "/images");
                        un       = Guid.NewGuid().ToString() + "_" + image.FileName;
                        filepath = Path.Combine(path, un);
                        using (var file = new FileStream(filepath, FileMode.Create))
                        {
                            await image.CopyToAsync(file);
                        }

                        tchr.TeacherPhoto = un;
                    }
                    else
                    {
                        var path = Path.Combine(_imagepath.WebRootPath + "/images");
                        un = Guid.NewGuid().ToString() + "_" + image.FileName;
                        string filepath = Path.Combine(path, un);
                        using (var file = new FileStream(filepath, FileMode.Create))
                        {
                            await image.CopyToAsync(file);
                        }
                        tchr.TeacherPhoto = un;
                    }
                }


                _context.Teacher.Update(tchr);
                await _context.SaveChangesAsync();


                ///Save the Document Information to the Database

                TeacherDocSubmitted doc = new TeacherDocSubmitted()
                {
                    TeacherId             = tr.TcridVM,
                    TeacherDocSubmittedId = tr.DocSLVM,
                    SSCCertificate        = tr.TcrdocsubhsccrtfctVM,
                    SSCMarksheet          = tr.TcrdocsubsscmarkVM,
                    HSCCertificate        = tr.TcrdocsubhsccrtfctVM,
                    HSCMarksheet          = tr.TcrdocsubhscmarkVM,
                    HonsCertificate       = tr.TcrdocsubhonscrtfctVM,
                    HonsMarksheet         = tr.TcrdocsubhonsmarkVM
                };

                _context.TeacherDocSubmitted.Update(doc);
                await _context.SaveChangesAsync();

                TeacherQualification tq = new TeacherQualification()
                {
                    TeacherQualificationId = tr.QlSLVM,
                    TeacherId     = tr.TcridVM,
                    SSCYear       = tr.TcrqsscyearVM,
                    SSCGrade      = tr.TcrqsscgradeVM,
                    SSCInstitute  = tr.TcrqsscinsVM,
                    HSCYear       = tr.TcrqhscyearVM,
                    HSCGrade      = tr.TcrqhscgradeVM,
                    HSCInstitute  = tr.TcrqhscinsVM,
                    HonsYear      = tr.TcrqhonsyearVM,
                    HonsGrade     = tr.TcrqhonsgradeVM,
                    HonsInstitute = tr.TcrqhonsinsVM
                };
                _context.TeacherQualification.Update(tq);
                await _context.SaveChangesAsync();



                return(RedirectToAction("TeacherList"));
            }
            else
            {
                return(View());
            }
        }
コード例 #8
0
        public async Task <IActionResult> AddTeacher(TeacherVm tr, IFormFile image)
        {
            if (ModelState.IsValid)
            {
                Teacher tchr = new Teacher()
                {
                    TeacherId          = 0,
                    TeacherName        = tr.TcrnameVM,
                    TeacherBG          = tr.TcrbgVM,
                    TeacherEmail       = tr.TcremailVM,
                    TeacherCAddress    = tr.TcrcaddrssVM,
                    TeacherPAddress    = tr.TcrpaddrssVM,
                    TeacherDOB         = tr.TcrdobVM,
                    TeacherGender      = tr.TcrgenderVM,
                    TeacherNationality = tr.TcrnationVM,
                    TeacherPhoneNo     = tr.TcrphoneVM,
                    TeacherJD          = DateTime.Now.Date,
                    TeacherPhoto       = tr.TcrphotoVM,
                    TeacherDesignation = tr.TcrdesigVM
                };
                string un = null;
                if (image != null)
                {
                    var path = Path.Combine(_imagepath.WebRootPath + "/images");
                    un = Guid.NewGuid().ToString() + "_" + image.FileName;
                    string filepath = Path.Combine(path, un);
                    using (var file = new FileStream(filepath, FileMode.Create))
                    {
                        await image.CopyToAsync(file);
                    }

                    tchr.TeacherPhoto = un;
                }

                _context.Teacher.Add(tchr);
                await _context.SaveChangesAsync();

                ///Get the id of teacher
                var TeacherId = tchr.TeacherId;
                //Teacher email
                var TeacherEmail = tchr.TeacherEmail;
                // Create random password
                PasswordGenerator ps = new PasswordGenerator();
                //Create login
                Login lg = new Login()
                {
                    LoginId          = 0,
                    Username         = TeacherEmail,
                    Password         = ps.RandomPassword(),
                    FirstLoginStatus = false,
                    ActiveStatus     = true,
                    RoleId           = 2,
                    DistinguishId    = TeacherId
                };
                lg.CurrentPassword = lg.Password;
                _context.Login.Add(lg);
                await _context.SaveChangesAsync();

                ///Save the Document Information to the Database

                TeacherDocSubmitted doc = new TeacherDocSubmitted()
                {
                    TeacherId             = TeacherId,
                    TeacherDocSubmittedId = 0,
                    SSCCertificate        = tr.TcrdocsubhsccrtfctVM,
                    SSCMarksheet          = tr.TcrdocsubsscmarkVM,
                    HSCCertificate        = tr.TcrdocsubhsccrtfctVM,
                    HSCMarksheet          = tr.TcrdocsubhscmarkVM,
                    HonsCertificate       = tr.TcrdocsubhonscrtfctVM,
                    HonsMarksheet         = tr.TcrdocsubhonsmarkVM
                };

                await _context.TeacherDocSubmitted.AddAsync(doc);

                await _context.SaveChangesAsync();

                TeacherQualification tq = new TeacherQualification()
                {
                    TeacherQualificationId = 0,
                    TeacherId     = TeacherId,
                    SSCYear       = tr.TcrqsscyearVM,
                    SSCGrade      = tr.TcrqsscgradeVM,
                    SSCInstitute  = tr.TcrqsscinsVM,
                    HSCYear       = tr.TcrqhscyearVM,
                    HSCGrade      = tr.TcrqhscgradeVM,
                    HSCInstitute  = tr.TcrqhscinsVM,
                    HonsYear      = tr.TcrqhonsyearVM,
                    HonsGrade     = tr.TcrqhonsgradeVM,
                    HonsInstitute = tr.TcrqhonsinsVM
                };
                await _context.TeacherQualification.AddAsync(tq);

                await _context.SaveChangesAsync();



                ///Clear the model state

                ModelState.Clear();
                return(View());
            }

            return(View());
        }