public ActionResult Create([Bind(Include = "batch_code,name,batch_starting_date,admission_last_date,room_number,faculty_name,amount,details,routine")] Batche batche)
        {
            if (ModelState.IsValid)
            {
                if (batche.admission_last_date >= batche.batch_starting_date)
                {
                    ModelState.AddModelError("admission_last_date", "Admission Last Date Cant Be Same As Batch Starting Date Or Greater Than Batch Starting Date!");
                    ViewBag.Day7           = MyCustomFunctions.Day7();
                    ViewBag.vendor_heading = new SelectList(db.Courses, "vendor_heading", "vendor_heading");
                    ViewBag.faculty_name   = new SelectList(db.Instructors, "faculty_name", "faculty_name");
                    ViewBag.name           = new SelectList(db.Courses, "name", "vendor_heading", batche.name);
                    return(View(batche));
                }
                db.Batches.Add(batche);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Day7           = MyCustomFunctions.Day7();
            ViewBag.vendor_heading = new SelectList(db.Courses, "vendor_heading", "vendor_heading");
            ViewBag.faculty_name   = new SelectList(db.Instructors, "faculty_name", "faculty_name");
            ViewBag.name           = new SelectList(db.Courses, "name", "vendor_heading", batche.name);

            return(View(batche));
        }
 public ActionResult Create()
 {
     ViewBag.Day7           = MyCustomFunctions.Day7();
     ViewBag.vendor_heading = new SelectList(db.Courses, "vendor_heading", "vendor_heading");
     ViewBag.faculty_name   = new SelectList(db.Instructors, "faculty_name", "faculty_name");
     ViewBag.name           = new SelectList(db.Courses, "name", "name");
     return(View());
 }
Exemplo n.º 3
0
        public ActionResult EditUserProfile(int?id)
        {
            if ((id ?? 0) == 0)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadGateway));
            }

            UserDetail userdetail = db.UserDetails.SingleOrDefault(m => m.id == id);

            ViewBag.user_activeList = MyCustomFunctions.UserActivity();
            return(View(userdetail));
        }
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            UserDetail userdetail = db.UserDetails.Find(id);

            if (userdetail == null)
            {
                return(HttpNotFound());
            }

            ViewBag.user_active = MyCustomFunctions.UserActivity();
            return(View(userdetail));
        }
Exemplo n.º 5
0
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Instructor instructor = db.Instructors.SingleOrDefault(m => m.InstructorId == id);

            if (instructor == null)
            {
                return(HttpNotFound());
            }

            ViewBag.faculty_active = MyCustomFunctions.UserActivity();
            return(View(instructor));
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            UserDetail userdetail = db.UserDetails.Find(id);

            if (userdetail == null)
            {
                return(HttpNotFound());
            }

            ViewBag.user_active = MyCustomFunctions.UserActivity();
            ViewBag.UserId      = new SelectList(db.Users, "UserId", "password", userdetail.UserId);
            return(View(userdetail));
        }
Exemplo n.º 7
0
        public ActionResult Details(int id = 0, string name = null)
        {
            Response.Write(id + " " + name);
            if (id == 0 && name == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Instructor instructor = db.Instructors.Where(x => x.InstructorId == id || x.faculty_name.Equals(name)).SingleOrDefault();

            if (instructor == null)
            {
                return(HttpNotFound());
            }

            ViewBag.faculty_active = MyCustomFunctions.UserActivity();
            return(View(instructor));
        }
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Batche batche = db.Batches.Find(id);

            if (batche == null)
            {
                return(HttpNotFound());
            }

            ViewBag.Day7 = MyCustomFunctions.Day7();
            ViewBag.vendor_headingList = new SelectList(db.Courses, "vendor_heading", "vendor_heading");
            ViewBag.faculty_nameList   = new SelectList(db.Instructors, "faculty_name", "faculty_name");
            ViewBag.nameList           = new SelectList(db.Courses, "name", "name", batche.name);
            return(View(batche));
        }
        public ActionResult Create([Bind(Include = "fullname,first_name,last_name,pic_path,company_name,city,phone_number,email,zip_code,nationality,sex,religion,blood_group,dob,user_activation_date")] UserDetail userdetail, HttpPostedFileBase pic_path)
        {
            ///create a student so level is student.....
            var SupportFileType = new[] { "image/gif", "image/x-png", "image/jpeg", "image/png" };

            if (ModelState.IsValid)
            {
                if (SupportFileType.Contains(pic_path.ContentType.ToLower().ToString()) == false)
                {
                    ModelState.AddModelError("pic_path", "Invalid File Type!");
                    return(View(userdetail));
                }
                else if (pic_path.ContentLength > (5 * 1024 * 1024))
                {
                    ModelState.AddModelError("pic_path", "Max File Size Is 5 MB!");
                    return(View(userdetail));
                }

                string pic           = Guid.NewGuid().ToString() + Path.GetFileName(pic_path.FileName);
                string CreateNewPath = "~/Content/img/tsms/student/" + pic;
                string userid        = MyCustomFunctions.GenerateUserId();
                db.UserDetails.Add(new UserDetail {
                    UserId               = userid,
                    first_name           = userdetail.first_name,
                    last_name            = userdetail.last_name,
                    fullname             = userdetail.fullname,
                    pic_path             = CreateNewPath,
                    company_name         = userdetail.company_name,
                    city                 = userdetail.city,
                    phone_number         = userdetail.phone_number,
                    email                = userdetail.email,
                    zip_code             = userdetail.zip_code,
                    nationality          = userdetail.nationality,
                    sex                  = userdetail.sex,
                    religion             = userdetail.religion,
                    blood_group          = userdetail.blood_group,
                    dob                  = userdetail.dob,
                    user_activation_date = DateTime.Now,
                    user_active          = userdetail.user_active,
                    User                 = new User()
                    {
                        UserId   = userid,
                        password = "******",
                        level    = "student"
                    }
                });
                try
                {
                    db.SaveChanges();
                    if (pic_path != null)
                    {
                        string path = System.IO.Path.Combine(Server.MapPath("~/Content/img/tsms/student/"), pic);
                        pic_path.SaveAs(path);
                    }
                }
                catch (System.Data.SqlClient.SqlException e)
                {
                    ModelState.AddModelError(null, e.ToString());
                    return(View(userdetail));
                }
                catch (System.Data.Entity.Infrastructure.DbUpdateException e)
                {
                    ModelState.AddModelError(null, e.ToString());
                    return(View(userdetail));
                }
                return(RedirectToAction("Index"));
            }

            ViewBag.user_active = MyCustomFunctions.UserActivity();
            return(View(userdetail));
        }
 public ActionResult Create()
 {
     ViewBag.user_active = MyCustomFunctions.UserActivity();
     return(View());
 }
        public ActionResult Edit([Bind(Include = "id,Modifyedpic_path,fullname,first_name,last_name,pic_path,company_name,city,phone_number,email,zip_code,nationality,sex,religion,blood_group,dob,user_deactivation_date,user_active")] UserDetail userdetail, HttpPostedFileBase Modifyedpic_path)
        {
            string pic             = null;
            var    SupportFileType = new[] { "image/gif", "image/x-png", "image/jpeg", "image/png" };

            //find old userdetails//
            UserDetail olduserdetail = db.UserDetails.SingleOrDefault(m => m.id == userdetail.id);
            string     oldPath       = Request.MapPath(olduserdetail.pic_path);

            if (Modifyedpic_path != null)
            {
                if (SupportFileType.Contains(Modifyedpic_path.ContentType.ToLower().ToString()) == false)
                {
                    ModelState.AddModelError("pic_path", "Invalid File Type!");
                    ViewBag.user_active = MyCustomFunctions.UserActivity();
                    ViewBag.UserId      = new SelectList(db.Users, "UserId", "password", userdetail.UserId);
                    return(View(userdetail));
                }
                else if (Modifyedpic_path.ContentLength > (5 * 1024 * 1024))
                {
                    ModelState.AddModelError("pic_path", "Max File Size Is 5 MB!");
                    ViewBag.user_active = MyCustomFunctions.UserActivity();
                    ViewBag.UserId      = new SelectList(db.Users, "UserId", "password", userdetail.UserId);
                    return(View(userdetail));
                }

                pic = Guid.NewGuid().ToString() + Path.GetFileName(Modifyedpic_path.FileName);
                string CreateNewPath = "~/Content/img/tsms/student/" + pic;

                olduserdetail.first_name             = userdetail.first_name;
                olduserdetail.last_name              = userdetail.last_name;
                olduserdetail.fullname               = userdetail.fullname;
                olduserdetail.pic_path               = CreateNewPath;
                olduserdetail.company_name           = userdetail.company_name;
                olduserdetail.city                   = userdetail.city;
                olduserdetail.phone_number           = userdetail.phone_number;
                olduserdetail.email                  = userdetail.email;
                olduserdetail.zip_code               = userdetail.zip_code;
                olduserdetail.nationality            = userdetail.nationality;
                olduserdetail.sex                    = userdetail.sex;
                olduserdetail.religion               = userdetail.religion;
                olduserdetail.blood_group            = userdetail.blood_group;
                olduserdetail.dob                    = userdetail.dob;
                olduserdetail.user_deactivation_date = userdetail.user_deactivation_date;
                olduserdetail.user_active            = userdetail.user_active;
            }
            else
            {
                TryUpdateModel(olduserdetail, new string[] { "fullname", "first_name", "last_name", "pic_path", "company_name", "city", "phone_number", "email", "zip_code", "nationality", "sex", "religion", "blood_group", "dob", "user_deactivation_date", "user_active" });
            }

            if (ModelState.IsValid)
            {
                try
                {
                    db.SaveChanges();
                    if (Modifyedpic_path != null)
                    {
                        if (System.IO.File.Exists(oldPath))
                        {
                            System.IO.File.Delete(oldPath);
                        }
                        string path = Path.Combine(Server.MapPath("~/Content/img/tsms/student/"), pic);
                        Modifyedpic_path.SaveAs(path);
                    }
                    return(RedirectToAction("Index"));
                }
                catch (System.Data.SqlClient.SqlException ex)
                {
                    ModelState.AddModelError(null, ex.ToString());
                    return(View(userdetail));
                }
                catch (System.Data.Entity.Infrastructure.DbUpdateException ex)
                {
                    ModelState.AddModelError(null, ex.ToString());
                    return(View(userdetail));
                }
            }

            ViewBag.user_active = MyCustomFunctions.UserActivity();
            ViewBag.UserId      = new SelectList(db.Users, "UserId", "password", userdetail.UserId);
            return(View(userdetail));
        }
Exemplo n.º 12
0
        public ActionResult Create([Bind(Include = "pic_path,first_name,last_name,faculty_name,company_name,city,phone_number,email,zip_code,nationality,sex,religion,blood_group,dob,faculty_active")] Instructor instructor, HttpPostedFileBase pic_path)
        {
            var SupportFileType = new[] { "image/gif", "image/x-png", "image/jpeg", "image/png" };

            if (ModelState.IsValid)
            {
                if (SupportFileType.Contains(pic_path.ContentType.ToLower().ToString()) == false)
                {
                    ModelState.AddModelError("pic_path", "Invalid File Type!");
                    ViewBag.faculty_active = MyCustomFunctions.UserActivity();
                    return(View(instructor));
                }
                else if (pic_path.ContentLength > (5 * 1024 * 1024))
                {
                    ModelState.AddModelError("pic_path", "Max File Size Is 5 MB!");
                    ViewBag.faculty_active = MyCustomFunctions.UserActivity();
                    return(View(instructor));
                }

                string pic           = Guid.NewGuid().ToString() + Path.GetFileName(pic_path.FileName);
                string CreateNewPath = "~/Content/img/tsms/instructor/" + pic;
                db.Instructors.Add(new Instructor
                {
                    faculty_name            = instructor.first_name + " " + instructor.last_name,
                    pic_path                = CreateNewPath,
                    first_name              = instructor.first_name,
                    last_name               = instructor.last_name,
                    company_name            = instructor.company_name,
                    city                    = instructor.city,
                    phone_number            = instructor.phone_number,
                    email                   = instructor.email,
                    zip_code                = instructor.zip_code,
                    nationality             = instructor.nationality,
                    sex                     = instructor.sex,
                    religion                = instructor.religion,
                    blood_group             = instructor.blood_group,
                    dob                     = instructor.dob,
                    faculty_activation_date = DateTime.Now,
                    faculty_active          = instructor.faculty_active,
                });
                try
                {
                    db.SaveChanges();
                    if (pic_path != null)
                    {
                        string path = System.IO.Path.Combine(Server.MapPath("~/Content/img/tsms/instructor/"), pic);
                        pic_path.SaveAs(path);
                    }
                }
                catch (System.Data.SqlClient.SqlException e)
                {
                    ModelState.AddModelError(null, e.ToString());
                    ViewBag.faculty_active = MyCustomFunctions.UserActivity();
                    return(View(instructor));
                }
                catch (System.Data.Entity.Infrastructure.DbUpdateException e)
                {
                    ModelState.AddModelError(null, e.ToString());
                    ViewBag.faculty_active = MyCustomFunctions.UserActivity();
                    return(View(instructor));
                }
                return(RedirectToAction("Index"));
            }

            ViewBag.faculty_active = MyCustomFunctions.UserActivity();
            return(View(instructor));
        }
Exemplo n.º 13
0
        public ActionResult Edit([Bind(Include = "Modifyedpic_path,InstructorId,pic_path,first_name,last_name,faculty_name,company_name,city,phone_number,email,zip_code,nationality,sex,religion,blood_group,dob,faculty_inactivation_date,faculty_active")] Instructor instructor, HttpPostedFileBase Modifyedpic_path)
        {
            string pic             = null;
            var    SupportFileType = new[] { "image/gif", "image/x-png", "image/jpeg", "image/png" };

            Instructor oldinstructor = db.Instructors.SingleOrDefault(m => m.InstructorId == instructor.InstructorId);
            string     oldPath       = Request.MapPath(oldinstructor.pic_path);

            if (Modifyedpic_path != null)
            {
                if (SupportFileType.Contains(Modifyedpic_path.ContentType.ToLower().ToString()) == false)
                {
                    ModelState.AddModelError("pic_path", "Invalid File Type!");
                    ViewBag.faculty_active = MyCustomFunctions.UserActivity();
                    return(View(instructor));
                }
                else if (Modifyedpic_path.ContentLength > (5 * 1024 * 1024))
                {
                    ModelState.AddModelError("pic_path", "Max File Size Is 5 MB!");
                    ViewBag.faculty_active = MyCustomFunctions.UserActivity();
                    return(View(instructor));
                }

                pic = Guid.NewGuid().ToString() + Path.GetFileName(Modifyedpic_path.FileName);
                string CreateNewPath = "~/Content/img/tsms/instructor/" + pic;

                oldinstructor.faculty_name = instructor.first_name + " " + instructor.last_name;
                oldinstructor.pic_path     = CreateNewPath;
                oldinstructor.first_name   = instructor.first_name;
                oldinstructor.last_name    = instructor.last_name;
                oldinstructor.company_name = instructor.company_name;
                oldinstructor.city         = instructor.city;
                oldinstructor.phone_number = instructor.phone_number;
                oldinstructor.email        = instructor.email;
                oldinstructor.zip_code     = instructor.zip_code;
                oldinstructor.nationality  = instructor.nationality;
                oldinstructor.sex          = instructor.sex;
                oldinstructor.religion     = instructor.religion;
                oldinstructor.blood_group  = instructor.blood_group;
                oldinstructor.dob          = instructor.dob;
                oldinstructor.faculty_inactivation_date = instructor.faculty_inactivation_date;
                oldinstructor.faculty_active            = instructor.faculty_active;
            }
            else
            {
                TryUpdateModel(oldinstructor, new string[] { "pic_path", "first_name", "last_name", "faculty_name", "company_name", "city", "phone_number", "email", "zip_code", "nationality", "sex", "religion", "blood_group", "dob", "faculty_inactivation_date", "faculty_active" });
            }

            if (ModelState.IsValid)
            {
                try
                {
                    db.SaveChanges();
                    if (Modifyedpic_path != null)
                    {
                        if (System.IO.File.Exists(oldPath))
                        {
                            System.IO.File.Delete(oldPath);
                        }
                        string path = Path.Combine(Server.MapPath("~/Content/img/tsms/instructor/"), pic);
                        Modifyedpic_path.SaveAs(path);
                    }
                    return(RedirectToAction("Index"));
                }
                catch (System.Data.SqlClient.SqlException ex)
                {
                    ModelState.AddModelError(null, ex.ToString());
                    ViewBag.faculty_active = MyCustomFunctions.UserActivity();
                    return(View(instructor));
                }
                catch (System.Data.Entity.Infrastructure.DbUpdateException ex)
                {
                    ModelState.AddModelError(null, ex.ToString());
                    ViewBag.faculty_active = MyCustomFunctions.UserActivity();
                    return(View(instructor));
                }
            }

            ViewBag.faculty_active = MyCustomFunctions.UserActivity();
            return(View(instructor));
        }