public HttpResponseMessage changepasswrd(Student Student)
        {
            try
            {
                return Request.CreateResponse(HttpStatusCode.OK, _repo.Changepassword(Student));
            }
            catch (Exception ex)
            {

                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }
        }
        public HttpResponseMessage GetstudentLogin(Student Student)
        {
            try
            {
                return Request.CreateResponse(HttpStatusCode.OK, _repo.GetStudentlogin(Student));
            }
            catch (Exception ex)
            {

                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }
        }
        public HttpResponseMessage updateloginDetail(Student student)
        {
            try
            {
                return Request.CreateResponse(HttpStatusCode.OK, _repo.UpdateStudentProfile(student));
            }
            catch (Exception)
            {

                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }
        }
        public HttpResponseMessage UploadResults(string id)
        {
            try
            {
                if (HttpContext.Current.Request.Files.AllKeys.Any())
                {
                    bool exists = System.IO.Directory.Exists(HttpContext.Current.Server.MapPath("~/UploadedFiles/StudentData/"+id));

                    if (!exists)
                        System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~/UploadedFiles/StudentData/") +id);
                    Student std = new Student();
                    std.ApplicantID = id;
                    foreach (string file in HttpContext.Current.Request.Files)
                    {
                        var filename = HttpContext.Current.Request.Files[file];
                        if (file.ToString() == "10thcert")
                        {
                            filename.SaveAs(Path.Combine(HttpContext.Current.Server.MapPath("~/UploadedFiles/StudentData/") + id, id+"_10thcertificate"+ Path.GetExtension(filename.FileName)));
                            std.cert10thURL = "~/UploadedFiles/StudentData/" + id+"/" + id + "_10thcertificate" + Path.GetExtension(filename.FileName);

                        }
                        if (file.ToString() == "12thcert")
                        {
                            filename.SaveAs(Path.Combine(HttpContext.Current.Server.MapPath("~/UploadedFiles/StudentData/") + id, id + "_12thcertificate" + Path.GetExtension(filename.FileName)));
                            std.cert12thURL = "~/UploadedFiles/StudentData/" + id+"/" + id + "_12thcertificate" + Path.GetExtension(filename.FileName);
                        }
                        if (file.ToString() == "domicilecert")
                        {
                            filename.SaveAs(Path.Combine(HttpContext.Current.Server.MapPath("~/UploadedFiles/StudentData/") + id, id + "_domicilecertificate" + Path.GetExtension(filename.FileName)));
                            std.domicilecertURL = "~/UploadedFiles/StudentData/" + id + "/" + id + "_domicilecertificate" + Path.GetExtension(filename.FileName);
                        }
                        if (file.ToString() == "aadharcrt")
                        {
                            filename.SaveAs(Path.Combine(HttpContext.Current.Server.MapPath("~/UploadedFiles/StudentData/") + id, id + "_aadharcertificate" + Path.GetExtension(filename.FileName)));
                            std.aadharcertURL = "~/UploadedFiles/StudentData/" + id + "/" + id + "_aadharcertificate" + Path.GetExtension(filename.FileName);
                        }
                    }
                    return Request.CreateResponse(HttpStatusCode.OK, _repo.UpdateStudentProfile(std));
                }
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }
            catch (Exception)
            {

                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }
        }
예제 #5
0
        public Student UpdateStudentProfile(Student std)
        {
            try
            {
                Student getstd = _context.Students.Where(x => x.ApplicantID == std.ApplicantID).FirstOrDefault();
                if (getstd != null)
                {
                    getstd.aadharcertURL = std.aadharcertURL;
                    getstd.cert10thURL = std.cert10thURL;
                    getstd.cert12thURL = std.cert12thURL;
                    getstd.domicilecertURL = std.domicilecertURL;
                    getstd.ModifiedDate = DateTime.Now;
                    _context.Entry(getstd).State = System.Data.Entity.EntityState.Modified;
                    SaveContext();
                    return getstd;
                }
                return null;
            }
            catch (Exception)
            {

                throw;
            }
        }
예제 #6
0
        public Student GetStudentlogin(Student std)
        {
            try
            {
                var a = _context.Students.Where(x => x.ApplicantID == std.ApplicantID && x.Password == std.Password).FirstOrDefault();
                return a;
            }
            catch (Exception)
            {

                throw;
            }
        }
예제 #7
0
        public bool Changepassword(Student std)
        {
            try
            {
                var a = _context.Students.Where(x => x.ApplicantID == std.ApplicantID && x.Password == std.Password).FirstOrDefault();
                if (a != null)
                {
                    a.Password = std.Newpassword;
                    _context.Entry(a).State = System.Data.Entity.EntityState.Modified;
                    SaveContext();
                    return true;
                }
                return false;
            }
            catch (Exception)
            {

                throw;
            }
        }
        public void UploadFile()
        {
            IExcelDataReader excelReader = null;
            Helper helper = new Helper();
            if (HttpContext.Current.Request.Files.AllKeys.Any())
            {
                bool exists = System.IO.Directory.Exists(HttpContext.Current.Server.MapPath("~/UploadedFiles/AdminData/ExcelUpload"));

                if (!exists)
                    System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~/UploadedFiles/AdminData/ExcelUpload"));
                // Get the uploaded image from the Files collection
               // var httpPostedFile1 = HttpContext.Current.Request.Files["StudentFile"];
                foreach(var httpPostedFile in HttpContext.Current.Request.Files)
                {
                    var fileSavePath = Path.Combine(HttpContext.Current.Server.MapPath("~/UploadedFiles/AdminData/ExcelUpload"), HttpContext.Current.Request.Files[httpPostedFile.ToString()].FileName);
                    HttpContext.Current.Request.Files[httpPostedFile.ToString()].SaveAs(fileSavePath);
                    FileStream stream = File.Open(fileSavePath, FileMode.Open, FileAccess.Read);

                    if (fileSavePath.Contains(".xls"))
                    {
                        //1. Reading from a binary Excel file ('97-2003 format; *.xls)
                        excelReader = ExcelReaderFactory.CreateBinaryReader(stream);
                    }
                    if (fileSavePath.Contains(".xlsx"))
                    {
                        //2. Reading from a OpenXml Excel file (2007 format; *.xlsx)
                        excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
                    }
                    //3. DataSet - The result of each spreadsheet will be created in the result.Tables
                    DataSet result = excelReader.AsDataSet();
                    //4. DataSet - Create column names from first row
                    excelReader.IsFirstRowAsColumnNames = true;
                    // DataSet result = excelReader.AsDataSet();

                    //5. Data Reader methods
                    IList<Student> Studentquery = new List<Student>();
                    while (excelReader.Read())
                    {
                        if (excelReader.Depth > 1)
                        {
                            Student sq = new Student();
                            sq.ApplicantID = excelReader[1].ToString();
                            sq.Name = excelReader[2].ToString();
                            sq.DOB = excelReader[3].ToString();
                            sq.SO = excelReader[4].ToString();
                            sq.Gender = excelReader[5].ToString() == "Male" ? Sex.Male : Sex.Female;
                            sq.Category = helper.Getcategory(excelReader[6].ToString());
                            sq.AdYear = excelReader[7].ToString();
                            sq.Course = _repo.GetCourse(excelReader[8].ToString());
                            sq.Password= excelReader[3].ToString();
                            if (_repo.GetStudentById(sq.ApplicantID) == null)
                            {
                                Studentquery.Add(sq);
                            }
                        }
                        //excelReader.GetInt32(0);
                    }

                    _repo.AddStudentList(Studentquery);
                    //6. Free resources (IExcelDataReader is IDisposable)
                    excelReader.Close();
                }

            }
        }