Ejemplo n.º 1
0
        // GET: Students/Create
        public ActionResult Create()
        {
            DeptRepo repo = new DeptRepo();

            ViewBag.Dept = new SelectList(repo.GetDept(), "DeptId", "Name");
            return(View());
        }
Ejemplo n.º 2
0
        public ActionResult Index(int page = 1)
        {
            var userManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context));
            /// get all users
            List <UserViewModel> model = new List <UserViewModel>();

            model = userManager.Users.Select(u => new UserViewModel
            {
                Id             = u.Id,
                Name           = u.UserName,
                Email          = u.UserName,
                EmailConfirmed = u.EmailConfirmed
            }).ToList();

            DeptRepo deptRepo = new DeptRepo(context);

            deptRepo.GetAll();
            var data = new DeptClassViewModel
            {
                ClassesPerPage = 10,
                DeptClasses    = deptRepo.GetAll(),
                CurrentPage    = page
            };



            return(View(data));
        }
Ejemplo n.º 3
0
        // GET: Students/Edit/5
        public ActionResult Edit(int id)
        {
            StudentRepo repo  = new StudentRepo();
            DeptRepo    drepo = new DeptRepo();

            ViewBag.Dept = new SelectList(drepo.GetDept(), "DeptId", "Name");
            return(View(repo.GetStudent().ToList().Find(d => d.StudentId == id)));
        }
Ejemplo n.º 4
0
        public ActionResult Index()
        {
            DeptRepo repo = new DeptRepo();

            ModelState.Clear();

            return(View(repo.GetDept()));
        }
Ejemplo n.º 5
0
 public ActionResult Edit(int id, Dept dept)
 {
     try
     {
         DeptRepo repo = new DeptRepo();
         repo.EditDept(dept);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Ejemplo n.º 6
0
        public ActionResult Delete(int id)
        {
            try
            {
                DeptRepo repo = new DeptRepo();
                repo.DeleteDept(id);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 7
0
        public ActionResult Create(Dept dept)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    DeptRepo repo = new DeptRepo();

                    repo.AddDept(dept);
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 8
0
        public ActionResult CreateDeptClass(FormCollection form)
        {
            using (var context1 = new ApplicationDbContext()){
                var data = new DeptClass()
                {
                    CreatedBy   = (string)User.Identity.GetUserId(),
                    CreatedOn   = DateTime.Now,
                    ModifiedOn  = DateTime.Now,
                    Name        = "New class",
                    Description = "new Description"
                };
                DeptRepo deptRepo = new DeptRepo(context1);
                deptRepo.Add(data);
            }



            return(Redirect("/Admin/Index"));
        }
Ejemplo n.º 9
0
        public ActionResult UploadFile(FormCollection form)
        {
            FilesRepo filesRepo = new FilesRepo(context);
            DeptRepo  deptRepo  = new DeptRepo(context);

            //string Username = form["txtFileName"];
            //file  = form.Get("profilepic");
            //string Password = form["password"];
            byte[] file            = null;
            string fileContentType = null;
            var    guid            = Guid.NewGuid();
            string classid         = form["txtClassDeptId"];
            var    DeptClassId     = Int16.Parse(classid);
            string fileName        = null;


            string folderName = @"C:\Proj";
            string name       = deptRepo.GetName(DeptClassId);

            if (Request != null)
            {
                HttpPostedFileBase file1 = Request.Files["File"];

                if ((file1 != null) && (file1.ContentLength > 0) && !string.IsNullOrEmpty(file1.FileName))
                {
                    fileName = file1.FileName;

                    fileContentType = file1.ContentType;
                    byte[] fileBytes = new byte[file1.ContentLength];
                    file1.InputStream.Read(fileBytes, 0, Convert.ToInt32(file1.ContentLength));
                    file = fileBytes;
                }
            }



            // To create a string that specifies the path to a subfolder under your
            // top-level folder, add a name for the subfolder to folderName.
            //\proj\className\file.pdf or tx
            string pathString  = System.IO.Path.Combine(folderName, name);
            string pathString1 = System.IO.Path.Combine(pathString, form["txtFileName"]);

            /// create the directory

            System.IO.Directory.CreateDirectory(pathString);

            if (!System.IO.File.Exists(pathString1))
            {
                // File.WriteAllBytes(Server.MapPath(filePath), imgArray);
                try
                {
                    System.IO.File.WriteAllBytes(pathString1, file);
                }catch (Exception e)
                {
                    e.ToString();
                    Console.WriteLine(e.ToString());
                }
            }
            else
            {
                Console.WriteLine("File \"{0}\" already exists.", pathString);
            }

            var data = new Files()
            {
                FileName          = form["txtFileName"],
                ContentType       = fileContentType,
                FilePathDirectory = pathString1,
                file        = file,
                CreatedBy   = (string)User.Identity.GetUserId(),
                DeptClassId = Int16.Parse(classid),
                CreatedOn   = DateTime.Now,
                ModifiedOn  = DateTime.Now
            };

            filesRepo.Add(data);



            return(Redirect("/Files?DeptClassId=" + DeptClassId));
        }
 public Dept1Controller(DeptRepo dept)
 {
     this.dept = dept;
 }
Ejemplo n.º 11
0
        public ActionResult Edit(int id)
        {
            DeptRepo repo = new DeptRepo();

            return(View(repo.GetDept().Find(d => d.DeptId == id)));
        }