public ActionResult Create(Course course)
        {
            //if (ModelState.IsValid)
            //{
            //    db.Courses.Add(course);
            //    db.SaveChanges();
            //    return RedirectToAction("Index");
            //}

            string fileName  = Path.GetFileNameWithoutExtension(course.file.FileName);
            string extension = Path.GetExtension(course.file.FileName);

            fileName        = fileName + DateTime.Now.ToString("yymmssff") + extension;
            course.Syllabus = "~/uploads/" + fileName;
            fileName        = Path.Combine(Server.MapPath("~/uploads/"), fileName);
            course.file.SaveAs(fileName);
            using (StudentServiceEntities db = new StudentServiceEntities())
            {
                db.Courses.Add(course);
                db.SaveChanges();
            }

            ViewBag.DepartmentCode = new SelectList(db.Departments, "DepartmentCode", "DepartmentName", course.DepartmentCode);
            ModelState.Clear();


            return(View(course));
        }
Exemplo n.º 2
0
        public ActionResult Create(Material material)
        {
            ViewBag.DepartmentCode = new SelectList(db.Departments, "DepartmentCode", "DepartmentCode", material.DepartmentCode);
            ViewBag.CourseCode     = new SelectList(db.Sections, "CourseCode", "CourseCode", material.CourseCode);
            ViewBag.SectionNumber  = new SelectList(db.Sections, "SectionNumber", "SectionNumber", material.SectionNumber);
            ViewBag.Semester       = new SelectList(db.Sections, "Semester", "Semester", material.Semester);
            ViewBag.Year           = new SelectList(db.Sections, "Year", "Year", material.Year);

            string fileName  = Path.GetFileNameWithoutExtension(material.file.FileName);
            string extension = Path.GetExtension(material.file.FileName);

            fileName     = fileName + DateTime.Now.ToString("yymmssff") + extension;
            material.PDF = "~/uploads/" + fileName;
            fileName     = Path.Combine(Server.MapPath("~/uploads/"), fileName);
            material.file.SaveAs(fileName);
            using (StudentServiceEntities db = new StudentServiceEntities())
            {
                db.Materials.Add(material);

                db.SaveChanges();
            }


            ModelState.Clear();
            return(View(material));
        }
Exemplo n.º 3
0
        public bool IsExsist(string email)
        {
            using (StudentServiceEntities dc = new StudentServiceEntities())
            {
                var v = dc.Students.Where(a => a.StudentEmail == email).FirstOrDefault();

                return(v != null);
            }
        }
        public bool IsExsist(string DepartmentCode)
        {
            using (StudentServiceEntities dc = new StudentServiceEntities())
            {
                var v = dc.Departments.Where(a => a.DepartmentCode == DepartmentCode).FirstOrDefault();

                return(v != null);
            }
        }
        public ActionResult Registration([Bind(Exclude = "Verification,ActivationCode")] Models.Student student)
        {
            bool   Status  = false;
            string Message = " ";

            if (ModelState.IsValid)
            {
                var isExsist = IsExsist(student.StudentEmail);
                if (isExsist)
                {
                    ModelState.AddModelError("EmailExist", "Email is already Exist");

                    return(View(student));
                }



                #region Generate Activation Code
                student.ActivationCode = Guid.NewGuid();
                #endregion

                #region Password Hashing
                student.Password         = Crypto.Hash(student.Password);
                student.ConfiremPassword = Crypto.Hash(student.ConfiremPassword);
                #endregion
                student.Verification = false;

                #region save data to data base
                using (StudentServiceEntities dc = new StudentServiceEntities())
                {
                    dc.Students.Add(student);
                    dc.SaveChanges();
                    //Send Email to User
                    Sendemailverifiction(student.StudentEmail, student.ActivationCode.ToString());
                    Message = "Registration successfully done. Account activation link " +
                              " has been sent to your email id:" + student.StudentEmail;
                    Status = true;
                }

                #endregion
            }
            else
            {
                Message = "Invalid Request";
            }
            ViewBag.Message = Message;
            ViewBag.Status  = Status;

            return(View(student));
        }
Exemplo n.º 6
0
        public ActionResult Login(login login, string ReturnUrl = "")
        {
            string Message = "";

            using (StudentServiceEntities dc = new StudentServiceEntities())
            {
                var v = dc.Students.Where(a => a.StudentEmail == login.StudentEmail).FirstOrDefault();
                if (v != null)
                {
                    if (!v.Verification)
                    {
                        ViewBag.Message = "Please verify your email first";
                        return(View());
                    }
                    if (string.Compare(Crypto.Hash(login.Password), v.Password) == 0)
                    {
                        int    timeout   = login.RememberMe ? 525600 : 20; // 525600 min = 1 year
                        var    ticket    = new FormsAuthenticationTicket(login.StudentEmail, login.RememberMe, timeout);
                        string encrypted = FormsAuthentication.Encrypt(ticket);
                        var    cookie    = new HttpCookie(FormsAuthentication.FormsCookieName, encrypted);
                        cookie.Expires  = DateTime.Now.AddMinutes(timeout);
                        cookie.HttpOnly = true;
                        Response.Cookies.Add(cookie);


                        if (Url.IsLocalUrl(ReturnUrl))
                        {
                            return(Redirect(ReturnUrl));
                        }

                        else
                        {
                            return(RedirectToAction("Index", "Home"));
                        }
                    }
                    else
                    {
                        Message = "Invalid Login ";
                    }
                }
                else
                {
                    Message = "Invalid Login";
                }
            }
            ViewBag.Message = Message;
            return(View());
        }
        public ActionResult Create(Project project)
        {
            string fileName  = Path.GetFileNameWithoutExtension(project.file.FileName);
            string extension = Path.GetExtension(project.file.FileName);

            fileName         = fileName + DateTime.Now.ToString("yymmssff") + extension;
            project.Abstract = "~/uploads/" + fileName;
            fileName         = Path.Combine(Server.MapPath("~/uploads/"), fileName);
            project.file.SaveAs(fileName);
            using (StudentServiceEntities db = new StudentServiceEntities())
            {
                db.Projects.Add(project);

                db.SaveChanges();
            }


            ModelState.Clear();
            return(View(project));
        }
Exemplo n.º 8
0
        public ActionResult VerifyAccount(string id)
        {
            bool Status = false;

            using (StudentServiceEntities dc = new StudentServiceEntities())
            {
                dc.Configuration.ValidateOnSaveEnabled = false; //to avoid

                var v = dc.Students.Where(a => a.ActivationCode == new Guid(id)).FirstOrDefault();
                if (v != null)
                {
                    v.Verification = true;
                    dc.SaveChanges();
                    Status = true;
                }
                else
                {
                    ViewBag.Message = "Invalid Request";
                }
            }
            ViewBag.Status = Status;
            return(View());
        }