Пример #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
        private void GetProfile(Contact contact)
        {
            contact.Load();

            var profiles = from profile in contact.Profiles.Entries where profile.Resource.Title == "GeneralProfile" select profile;

            if (profiles.ToList().Count > 0)
            {
                Profile tmp = profiles.First();
                this.generalProfile = tmp.Resource.ProfileInfo as GeneralProfile;
            }
        }
Пример #3
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);
            }
        }
        public IActionResult GeneralProfile(GeneralProfile 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);

            // When Save button is clicked
            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));

                    // 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.AddFromAccountGeneralProfile(generalProfile, uniqueFileName);
                }
                else
                {
                    // Adding generalProfile attr to user without image
                    _user.AddFromAccountGeneralProfile(generalProfile);
                }
                _context.Users.Update(_user);
                _context.SaveChanges();
                GeneralProfile gen = new GeneralProfile(_user);
                return(View(gen));
            }
        }
        private static void Load()
        {
            if (!System.IO.File.Exists(Constants.SettingsFile))
            {
                _profile = new GeneralProfile();
                return;
            }

            var json = System.IO.File.ReadAllText(Constants.SettingsFile);

            try
            {
                _profile = Newtonsoft.Json.JsonConvert.DeserializeObject <GeneralProfile>(
                    System.IO.File.ReadAllText(Constants.SettingsFile));
            }
            catch
            {
                System.IO.File.Delete(Constants.SettingsFile);
                Load();
            }
        }