예제 #1
0
        public IActionResult GeneralProfile(GeneralProfile generalProfile)
        {
            
            using (GlobalDBContext _context = new GlobalDBContext())
            {
                if (generalProfile.UserImage != null && generalProfile.UserImage.Length > 0)
                {
                    string uploadFolder = _env.WebRootPath + @"\uploads\UserImage\";
                    string uniqueFileName = Guid.NewGuid().ToString() + "_" + generalProfile.UserImage.FileName;
                    string filePath = uploadFolder + uniqueFileName;
                    generalProfile.UserImage.CopyTo(new FileStream(filePath, FileMode.Create));
                    // if new image is uploaded with other user info
                    _user.AddFromAccountGeneralProfile(generalProfile, uniqueFileName);
                    
                    // Delete previous uploaded Image
                    if (!String.IsNullOrEmpty(_user.UserImage))
                    {
                        string imagePath = uploadFolder + _user.UserImage;
                        Directory.Delete(imagePath);
                    }
                }
                else
                {
                    // Adding generalProfile attr to user without image
                    _user.AddFromAccountGeneralProfile(generalProfile);
                }
                _context.Users.Update(_user);
                _context.SaveChanges();
                GeneralProfile gen = new GeneralProfile(_user);
                string path = _env.ContentRootPath + @"\Data\DashboardMenuOptions.json";
                ViewData["menuItems"] = HelpersFunctions.GetMenuOptionsForUser(_user.UserId, path);
                return View(gen);
            }

        }
예제 #2
0
        public IActionResult Index()
        {
            // Display User name on the right-top corner - shows user is logedIN
            ViewData["LoggeduserName"] = new List <string>()
            {
                _user.UserFirstName + ' ' + _user.UserLastName, _user.UserImage
            };

            // Geting Dashboard Menu from project/data/DashboardMenuOption.json into ViewData
            string path = _env.ContentRootPath + @"\Data\DashboardMenuOptions.json";

            ViewData["menuItems"] = HelpersFunctions.GetMenuOptionsForUser(_user.UserId, path);

            using (GlobalDBContext _context = new GlobalDBContext())
            {
                // Geting internshps student applied for using his/her userID
                var appliedInterns        = _context.AppliedInternships.Include(i => i.Internship).Where(e => e.User == _user).ToList();
                List <Internship> interns = new List <Internship>();
                foreach (var appliedIntern in appliedInterns)
                {
                    Internship theIntern = appliedIntern.Internship;
                    interns.Add(theIntern);
                }
            }
            return(View());
        }
        public IActionResult GeneralProfile(ProfileViewEmployer fromData)
        {
            using (GlobalDBContext _context = new GlobalDBContext())
            {
                if (fromData.UserImage != null && fromData.UserImage.Length > 0)
                {
                    string uploadFolder = _env.WebRootPath + @"\uploads\UserImage\";

                    // File of code need to be Tested
                    //string file_Path = HelpersFunctions.StoreFile(uploadFolder, generalProfile.UserImage);

                    string     uniqueFileName = Guid.NewGuid().ToString() + "_" + fromData.UserImage.FileName;
                    string     filePath       = uploadFolder + uniqueFileName;
                    FileStream stream         = new FileStream(filePath, FileMode.Create);
                    fromData.UserImage.CopyTo(stream);
                    stream.Dispose();

                    // Delete previous uploaded Image
                    if (!String.IsNullOrEmpty(_user.UserImage))
                    {
                        string imagePath = uploadFolder + _user.UserImage;
                        if (System.IO.File.Exists(imagePath))
                        {
                            // If file found, delete it
                            System.IO.File.Delete(imagePath);
                            Console.WriteLine("File deleted.");
                        }
                    }
                    // if new image is uploaded with other user info
                    _user.AddFromEmployerProfileView(fromData, uniqueFileName);
                }
                else
                {
                    // Adding generalProfile attr to user without image
                    _user.AddFromEmployerProfileView(fromData);
                }
                _context.Users.Update(_user);
                _context.SaveChanges();
                fromData.UserImageName = _user.UserImage;

                // Display User name on the right-top corner - shows user is logedIN
                ViewData["LoggeduserName"] = new List <string>()
                {
                    _user.UserFirstName + ' ' + _user.UserLastName, _user.UserImage
                };
                // Geting Dashboard Menu from project/data/DashboardMenuOption.json into ViewData
                string path = _env.ContentRootPath + @"\Data\DashboardMenuOptions.json";
                ViewData["menuItems"] = HelpersFunctions.GetMenuOptionsForUser(_user.UserId, path);
                //-------------------- END

                return(View(fromData));
            }
        }
        //Create CreateInternController
        public IActionResult CreateInternships()
        {
            ViewData["LoggeduserName"] = new List <string>()
            {
                _user.UserFirstName + ' ' + _user.UserLastName, _user.UserImage
            };

            // Geting Dashboard Menu from project/data/DashboardMenuOption.json into ViewData
            string path = _env.ContentRootPath + @"\Data\DashboardMenuOptions.json";

            ViewData["menuItems"] = HelpersFunctions.GetMenuOptionsForUser(_user.UserId, path);

            return(View());
        }
        public IActionResult CreateCourses()
        {
            // Display User name on the right-top corner - shows user is logedIN
            ViewData["LoggeduserName"] = new List <string>()
            {
                _user.UserFirstName + ' ' + _user.UserLastName, _user.UserImage
            };

            // Geting Dashboard Menu from project/data/DashboardMenuOption.json into ViewData
            string path = _env.ContentRootPath + @"\Data\DashboardMenuOptions.json";

            ViewData["menuItems"] = HelpersFunctions.GetMenuOptionsForUser(_user.UserId, path);

            return(View());
        }
예제 #6
0
        public IActionResult GeneralProfile()
        {
            // Display User name on the right-top corner - shows user is logedIN
            ViewData["LoggeduserName"] = _user.UserFirstName + ' ' + _user.UserLastName;

            // Geting Dashboard Menu from project/data/DashboardMenuOption.json into ViewData
            string path = _env.ContentRootPath + @"\Data\DashboardMenuOptions.json";
            ViewData["menuItems"] = HelpersFunctions.GetMenuOptionsForUser(_user.UserId, path);

            using (GlobalDBContext _context = new GlobalDBContext())
            {
                GeneralProfile gen = new GeneralProfile(_user);
                return View(gen);
            }
        }
예제 #7
0
        public IActionResult Index()
        {
            // Display User name on the right-top corner - shows user is logedIN
            ViewData["LoggeduserName"] = _user.UserFirstName + ' ' + _user.UserLastName;

            // Geting Dashboard Menu from project/data/DashboardMenuOption.json into ViewData
            string path = _env.ContentRootPath + @"\Data\DashboardMenuOptions.json";
            ViewData["menuItems"] = HelpersFunctions.GetMenuOptionsForUser(_user.UserId, path);

            using (GlobalDBContext _context = new GlobalDBContext())
            {
                // Gets all internship created by the user
                ViewBag.IntershipsByLoginedInUser = _context.Internships.Where(e => e.User == _user).ToList();
                return View();
            }
        }
예제 #8
0
        public IActionResult GeneralProfile(ProfileViewStudent fromData)
        {
            // Display User name on the right-top corner - shows user is logedIN
            ViewData["LoggeduserName"] = new List <string>()
            {
                _user.UserFirstName + ' ' + _user.UserLastName, _user.UserImage
            };

            // Geting Dashboard Menu from project/data/DashboardMenuOption.json into ViewData
            string path = _env.ContentRootPath + @"\Data\DashboardMenuOptions.json";

            ViewData["menuItems"] = HelpersFunctions.GetMenuOptionsForUser(_user.UserId, path);

            // When Save button is clicked
            using (GlobalDBContext _context = new GlobalDBContext())
            {
                if (fromData.UserImage != null && fromData.UserImage.Length > 0)
                {
                    string uploadFolder   = _env.WebRootPath + @"\uploads\UserImage\";
                    string uniqueFileName = Guid.NewGuid().ToString() + "_" + fromData.UserImage.FileName;
                    string filePath       = uploadFolder + uniqueFileName;
                    fromData.UserImage.CopyTo(new FileStream(filePath, FileMode.Create));

                    // Delete previous uploaded Image
                    if (!String.IsNullOrEmpty(_user.UserImage))
                    {
                        string imagePath = uploadFolder + _user.UserImage;
                        System.IO.File.Delete(imagePath);
                    }

                    // if new image is uploaded with other user info
                    _user.AddFromStudentProfileView(fromData, uniqueFileName);
                }
                else
                {
                    // Adding generalProfile attr to user without image
                    _user.AddFromStudentProfileView(fromData);
                }
                _context.Users.Update(_user);
                _context.SaveChanges();
                ProfileViewStudent gen = new ProfileViewStudent(_user);
                return(View(gen));
            }
        }
        public IActionResult GeneralProfile()
        {
            // Display User name on the right-top corner - shows user is logedIN
            ViewData["LoggeduserName"] = new List <string>()
            {
                _user.UserFirstName + ' ' + _user.UserLastName, _user.UserImage
            };
            // Geting Dashboard Menu from project/data/DashboardMenuOption.json into ViewData
            string path = _env.ContentRootPath + @"\Data\DashboardMenuOptions.json";

            ViewData["menuItems"] = HelpersFunctions.GetMenuOptionsForUser(_user.UserId, path);
            //-------------------- END

            using (GlobalDBContext _context = new GlobalDBContext())
            {
                ProfileViewEmployer userViewModel = new ProfileViewEmployer(_user);
                return(View(userViewModel));
            }
        }
        public IActionResult CreateCourses(Course NewCourse)
        {
            // Display User name on the right-top corner - shows user is logedIN
            ViewData["LoggeduserName"] = new List <string>()
            {
                _user.UserFirstName + ' ' + _user.UserLastName, _user.UserImage
            };

            // Geting Dashboard Menu from project/data/DashboardMenuOption.json into ViewData
            string path = _env.ContentRootPath + @"\Data\DashboardMenuOptions.json";

            ViewData["menuItems"] = HelpersFunctions.GetMenuOptionsForUser(_user.UserId, path);

            var User_id = _customAuthManager.Tokens.FirstOrDefault().Value.Item3;

            var WhatIsThis = _customAuthManager.Tokens.FirstOrDefault().Value.Item1;

            var WhatIsThis1 = _customAuthManager.Tokens.FirstOrDefault().Value.Item2;

            //var WhatIsThis2 = _customAuthManager.Tokens.FirstOrDefault().Value.GetType;

            using (GlobalDBContext _context = new GlobalDBContext())
            {
                Course nCourse = new Course();

                //User user = _context.Users.Find(User_id);

                User user = _context.Users.Find(User_id);

                //this creates new course
                nCourse.CreateNewCourse(NewCourse, user);

                _context.Course.Add(nCourse);

                _context.SaveChanges();

                ViewBag.Message = NewCourse.CourseTitle + " successfully created check the courses table to see if it has been created" + WhatIsThis + "//" + WhatIsThis1;
            }
            return(View());
        }
        public IActionResult GeneralProfile(User UpdateDetails)
        {
            // Display User name on the right-top corner - shows user is logedIN
            ViewData["LoggeduserName"] = new List <string>()
            {
                _user.UserFirstName + ' ' + _user.UserLastName, _user.UserImage
            };

            // Geting Dashboard Menu from project/data/DashboardMenuOption.json into ViewData
            string path = _env.ContentRootPath + @"\Data\DashboardMenuOptions.json";

            ViewData["menuItems"] = HelpersFunctions.GetMenuOptionsForUser(_user.UserId, path);

            var User_id = _customAuthManager.Tokens.FirstOrDefault().Value.Item3;

            GlobalDBContext _context = new GlobalDBContext();

            //assigns the new values to the updated ones
            _user.UserFirstName = UpdateDetails.UserFirstName;
            _user.UserLastName  = UpdateDetails.UserLastName;
            _user.UserAddress   = UpdateDetails.UserAddress;
            _user.UserCity      = UpdateDetails.UserCity;
            _user.CreatedAt     = UpdateDetails.CreatedAt;
            _user.UserState     = UpdateDetails.UserState;
            _user.UserCountry   = UpdateDetails.UserCountry;
            _user.UserZip       = UpdateDetails.UserZip;
            _user.UserImage     = UpdateDetails.UserImage;
            _user.UserGender    = UpdateDetails.UserGender;

            _context.Users.Update(_user);

            _context.SaveChanges();

            ViewBag.Message = _user.UserFirstName + " " + _user.UserLastName + " has been updated successfully. Check the Users table to see if it has been updated.";

            return(View(_user));
        }
        public IActionResult CompanyDetails()
        {
            // Display User name on the right-top corner - shows user is logedIN
            ViewData["LoggeduserName"] = new List <string>()
            {
                _user.UserFirstName + ' ' + _user.UserLastName, _user.UserImage
            };

            // Geting Dashboard Menu from project/data/DashboardMenuOption.json into ViewData
            string path = _env.ContentRootPath + @"\Data\DashboardMenuOptions.json";

            ViewData["menuItems"] = HelpersFunctions.GetMenuOptionsForUser(_user.UserId, path);

            using (GlobalDBContext _context = new GlobalDBContext())
            {
                UserCompany companyInfo = _context.UserCompany.Include(u => u.User).FirstOrDefault(e => e.User.UserId == _user.UserId);
                Global_Intern.Models.EmployerModels.EmployerCompanyModel model = new Models.EmployerModels.EmployerCompanyModel();
                if (companyInfo != null)
                {
                    model = new Models.EmployerModels.EmployerCompanyModel(companyInfo);
                }
                return(View(model));
            }
        }
예제 #13
0
 public IActionResult InternshipApply(int?id, ApplyInternship fromData)
 {
     // the User is student
     // Make changes to AppliedInternship table.
     //  make nortfication.
     using (GlobalDBContext _context = new GlobalDBContext())
     {
         string FinalCVPath;
         string FinalCLPath;
         string FinalCLString = null;
         // CV
         if (fromData.TemporaryCV != null && fromData.TemporaryCV.Length > 0)
         {
             string UserCVFolder = _env.WebRootPath + @"\uploads\UserCV\";
             // File of code need to be Tested
             FinalCVPath = HelpersFunctions.StoreFile(UserCVFolder, fromData.TemporaryCV);
         }
         else
         {
             if (fromData.isCVExisting)
             {
                 UserDocument Doc = _context.UserDocuments.Include(u => u.User).FirstOrDefault(p =>
                                                                                               p.User.UserId == _user.UserId && p.DocumentType == "CV");
                 FinalCVPath = Doc.DocumentPath;
             }
             else
             {
                 FinalCVPath = null;
             }
         }
         // COVER Letter
         if (fromData.TemporaryCL != null && fromData.TemporaryCL.Length > 0)
         {
             string UserCLFolder = _env.WebRootPath + @"\uploads\UserCL\";
             // File of code need to be Tested
             FinalCLPath = HelpersFunctions.StoreFile(UserCLFolder, fromData.TemporaryCL);
         }
         else
         {
             if (fromData.isCLExisting)
             {
                 UserDocument Doc = _context.UserDocuments.Include(u => u.User).FirstOrDefault(p =>
                                                                                               p.User.UserId == _user.UserId && p.DocumentType == "CL");
                 FinalCLPath = Doc.DocumentPath;
             }
             else
             {
                 FinalCLPath = null;
                 if (fromData.isCLTextArea)
                 {
                     FinalCLString = fromData.WrittenCL;
                 }
                 else
                 {
                     FinalCLString = null;
                 }
             }
         }
         Internship intern = _context.Internships.Find(id);
         // AppliedInternship constructor takes User and Internship object to create AppliedInternship object
         AppliedInternship APP_Intern = new AppliedInternship(_user, intern)
         {
             TempCVPath      = FinalCVPath,
             TempCLPath      = FinalCLPath,
             CoverLetterText = FinalCLString,
             EmployerStatus  = "Pending"
         };
         // Adding who applied the intership
         _context.AppliedInternships.Add(APP_Intern);
         _context.SaveChanges();
         return(View());
     }
 }