コード例 #1
0
        public IActionResult UpdateUserPreference(int userId, [FromBody] UserPreferenceDto userPreferenceDto)
        {
            var userPreference = _mapper.Map <UserPreference>(userPreferenceDto);
            var result         = _userService.UpdateUserPreference(userId, userPreference);

            return(result ? Ok() : StatusCode(500));
        }
コード例 #2
0
        public ActionResult TrackReleaseNoteInfoModalShown()
        {
            var releaseNoteShownUserPreference = GetReleaseNoteShownUserPreference();
            var currentAppVersion = typeof(HomeController).Assembly.GetCustomAttribute <AssemblyInformationalVersionAttribute>().InformationalVersion;

            if (releaseNoteShownUserPreference == null)
            {
                var userPreferenceDto = new UserPreferenceDto
                {
                    ControlId    = ReleaseNoteControlId,
                    UserGuid     = Guid.Parse(User.Identity.GetUserId()),
                    SettingsJson = JsonConvert.SerializeObject(new ReleaseNoteShownPreferenceDto {
                        Version = currentAppVersion
                    })
                };
                Factory.Save <IUserPreferenceDto>(userPreferenceDto);
            }
            else
            {
                var settings = releaseNoteShownUserPreference.GetSettings <ReleaseNoteShownPreferenceDto>();
                if (settings.Version != currentAppVersion)
                {
                    settings.Version = currentAppVersion;
                    releaseNoteShownUserPreference.SettingsJson = JsonConvert.SerializeObject(settings);
                    Factory.Save <IUserPreferenceDto>(releaseNoteShownUserPreference);
                }
            }

            return(new EmptyResult());
        }
コード例 #3
0
        public ActionResult TrackAgingRepairsModalShown()
        {
            var agedRepairsUserPreference = GetAgedRepairsUserPreference();

            if (agedRepairsUserPreference == null)
            {
                var userPreferenceDto = new UserPreferenceDto
                {
                    ControlId    = "ShowAgedRepairs",
                    UserGuid     = Guid.Parse(User.Identity.GetUserId()),
                    SettingsJson = JsonConvert.SerializeObject(new AgedRepairsUserPreferenceDto {
                        Date = DateTime.UtcNow.Date
                    })
                };
                Factory.Save <IUserPreferenceDto>(userPreferenceDto);
            }
            else
            {
                var settings = agedRepairsUserPreference.GetSettings <AgedRepairsUserPreferenceDto>();
                if (settings.Date.Date != DateTime.UtcNow.Date)
                {
                    settings.Date = DateTime.UtcNow.Date;
                    agedRepairsUserPreference.SettingsJson = JsonConvert.SerializeObject(settings);
                    Factory.Save <IUserPreferenceDto>(agedRepairsUserPreference);
                }
            }

            return(null);
        }
コード例 #4
0
        public void UpdateCoveragePreferences(TechnicianCoverageUserPreferenceDto preference)
        {
            IUserPreferenceDto userPrefernce = new UserPreferenceDto
            {
                UserGuid     = Guid.Parse(User.Identity.GetUserId()),
                ControlId    = nameof(TechnicianCoverageUserPreferenceDto),
                SettingsJson = JsonConvert.SerializeObject(preference)
            };

            Factory.Save(userPrefernce);
        }