コード例 #1
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));
            }
        }
コード例 #2
0
        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);


            using (GlobalDBContext _context = new GlobalDBContext())
            {
                ProfileViewStudent gen = new ProfileViewStudent(_user);

                return(View(gen));
            }
        }