Example #1
0
        public ActionResult HireInstructor(Instructer instructer)
        {
            Dbcontext db      = new Dbcontext();
            int       counter = 0;
            long      uno     = DateTime.Now.Ticks;

            foreach (string fileName in Request.Files)
            {
                HttpPostedFileBase file = Request.Files[fileName];
                if (!string.IsNullOrEmpty(file.FileName))
                {
                    string abc = uno + "_" + ++counter +
                                 file.FileName.Substring(file.FileName.LastIndexOf("."));
                    string url  = "~/Content/InstructorImages/" + abc;
                    string path = Request.MapPath(url);
                    instructer.ImageUrl = abc;
                    file.SaveAs(path);
                }
            }
            using (db)
            {
                db.Instructers.Add(instructer);
                db.SaveChanges();
            }
            return(View());
        }
Example #2
0
        public ActionResult DeleteInst(int id)
        {
            Dbcontext  db = new Dbcontext();
            Instructer p  = (from c in db.Instructers
                             where c.Id == id
                             select c).FirstOrDefault();

            db.Entry(p).State = EntityState.Deleted;
            db.SaveChanges();
            return(Json("Delete", JsonRequestBehavior.AllowGet));
        }
Example #3
0
        public ActionResult UpdateInstructor(Instructer instructer)
        {
            Dbcontext db = new Dbcontext();

            using (db)
            {
                db.Entry(instructer).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index", "Instructor"));
            }
        }