Esempio n. 1
0
 //
 // GET: /Metrics/
 public ActionResult Index(UserSettingsModel newSettings = null)
 {
     using (var context = new HearthstoneContext())
     {
         var user = (from u in context.UserProfiles.Include("DecksForUsers").Include("DecksForUsers.Deck").Include("SimpleStats")
                     where u.UserName == User.Identity.Name
                     select u).FirstOrDefault();
         if (newSettings == null)
         {
             newSettings = user.UserSettings.FirstOrDefault();
         }
         else
         {
             var oldSettings = user.UserSettings.FirstOrDefault();
             if (oldSettings == null)
             {
                 if (newSettings.Metrics == null) newSettings.Metrics = new MetricsModel();
                 if (newSettings.UserID == 0) newSettings.UserID = user.UserId;
                 context.Settings.Add(newSettings);
                 context.Metrics.Add(newSettings.Metrics);
             }
             else
             {
                 if (newSettings.Metrics != null)
                 {
                     oldSettings.Metrics.BadgeID = newSettings.Metrics.BadgeID;
                     oldSettings.Metrics.DeckID = newSettings.Metrics.DeckID;
                     oldSettings.Metrics.deckType = newSettings.Metrics.deckType;
                     oldSettings.Metrics.EndDate = newSettings.Metrics.EndDate;
                     oldSettings.Metrics.StartDate = newSettings.Metrics.StartDate;
                     oldSettings.Metrics.HeroID = newSettings.Metrics.HeroID;
                     newSettings.Metrics.MetricsModelID = oldSettings.Metrics.MetricsModelID;
                     oldSettings.Metrics.IncludeBaseStats = newSettings.Metrics.IncludeBaseStats;
                 }
                 else
                 {
                     newSettings = oldSettings;
                 }
             }
             context.SaveChanges();
         }
         if (newSettings == null) newSettings = new UserSettingsModel();
         if (newSettings.Metrics == null) newSettings.Metrics = new MetricsModel();
         if (newSettings.User == null) newSettings.User = user;
         return View(newSettings);
     }
 }
Esempio n. 2
0
        public IActionResult UserSettings(UserSettingsModel model)
        {
            if (ModelState.IsValid)
            {
                Entity entity = new Entity("SystemUserSettings");
                entity.SetIdValue(model.SystemUserSettingsId)
                .SetAttributeValue("paginglimit", model.PagingLimit)
                .SetAttributeValue("languageuniqueid", model.LanguageUniqueId)
                .SetAttributeValue("transactioncurrencyid", model.CurrencyId)
                .SetAttributeValue("EnabledNotification", model.EnabledNotification);

                _dataUpdater.Update(entity);
                if (model.LanguageUniqueId != (int)CurrentUser.UserSettings.LanguageId)
                {
                    WebContext.T.ReFresh();
                }

                return(SaveSuccess());
            }

            return(SaveFailure(GetModelErrors()));
        }
 public void UpdateUserSettingsXmlFile(string filePath, UserSettingsModel userSettings)
 {
     using (var xmlWriter = XmlWriter.Create(filePath, xmlWriterSettings))
     {
         xmlWriter.WriteStartDocument();
         xmlWriter.WriteStartElement("UserSettings");
         xmlWriter.WriteStartElement("ServerConnection");
         xmlWriter.WriteElementString("DefaultServerAddress", userSettings.DefaultServerAddress);
         xmlWriter.WriteElementString("DefaultServerPort", userSettings.DefaultServerPort.ToString());
         xmlWriter.WriteEndElement();
         xmlWriter.WriteStartElement("OutputFile");
         xmlWriter.WriteElementString("DefaultOutputDirectory", userSettings.DefaultOutputDirectory);
         xmlWriter.WriteElementString("DefaultFileName", userSettings.DefaultFileName);
         xmlWriter.WriteElementString("AutomaticallySaveToFile", userSettings.AutomaticallySaveToFile.ToString());
         xmlWriter.WriteEndElement();
         xmlWriter.WriteStartElement("Layout");
         xmlWriter.WriteElementString("AutomaticallyExpandQuickCommands", userSettings.AutomaticallyExpandQuickCommands.ToString());
         xmlWriter.WriteEndElement();
         xmlWriter.WriteEndElement();
         xmlWriter.WriteEndDocument();
     }
 }
Esempio n. 4
0
        public async Task <IActionResult> PostAsync(string entityType, UserSettingsModel userSettingDetail)
        {
            if (userSettingDetail == null)
            {
                return(this.BadRequest("User setting details can not be null."));
            }

            this.RecordEvent("UserSettings - HTTP Post call to add userSetting details.", RequestType.Initiated);
            this.logger.LogInformation("Call to add userSetting details.");

            try
            {
                var existingUserSetting = await this.unitOfWork.UserSettingRepository.GetAsync(this.UserObjectId);

                if (existingUserSetting == null)
                {
                    var userSettingEntityModel = this.userSettingMapper.CreateMap(userSettingDetail, entityType, this.UserObjectId);
                    this.unitOfWork.UserSettingRepository.Add(userSettingEntityModel);
                }
                else
                {
                    this.userSettingMapper.UpdateMap(userSettingDetail, existingUserSetting, entityType);
                    this.unitOfWork.UserSettingRepository.Update(existingUserSetting);
                }

                await this.unitOfWork.SaveChangesAsync();

                this.RecordEvent("UserSettings - HTTP Post call succeeded.", RequestType.Succeeded);

                return(this.Ok(true));
            }
            catch (Exception ex)
            {
                this.RecordEvent("UserSettings - HTTP Post call failed for saving userSetting data", RequestType.Failed);
                this.logger.LogError(ex, "Error while saving userSetting details");
                throw;
            }
        }
Esempio n. 5
0
        public async Task <OperationResult> UpdateUserSettings(UserSettingsModel model)
        {
            var user = await _userService.GetCurrentUserAsync();

            if (user == null)
            {
                return(new OperationResult(false, _localizationService.GetString("UserNotFound")));
            }

            user.Locale    = model.Locale;
            user.TimeZone  = model.TimeZone;
            user.Formats   = model.Formats;
            user.DarkTheme = model.DarkTheme;
            var updateResult = await _userManager.UpdateAsync(user);

            if (!updateResult.Succeeded)
            {
                return(new OperationResult(false,
                                           $"Error while updating user settings: {string.Join(", ", updateResult.Errors.Select(x => x.Description).ToArray())}"));
            }

            return(new OperationResult(true));
        }
Esempio n. 6
0
        private async Task GetAsync()
        {
            mapper = new AutoMapperTest();
            mapper.Reset();
            mapper.IsValidConfiguration();
            UserSettingsModel dummyUSM = new UserSettingsModel();

            Entities.UserSetting userSettingsReturn = new UserSetting();
            var genericIdentity = new API.Authorization.User("4", true, "dummyUser", API.Authorization.User.IarUserTypes.User, "", "", DateTime.Now, 125625, 168);

            _controller = new UserSettingsController(_mock.Object, _mockUW.Object, new ApplicationContext(genericIdentity));
            _mockBC.Setup(m => m.Accepted());
            User user = new User();

            _mock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(dummyUSM);
            Assert.NotNull(dummyUSM);
            _mockUW.Setup(m => m.UserSettingsRepository.GetDefaultSettings()).Returns(userSettingsReturn);
            _mockUW.Setup(m => m.UserSettingsRepository.GetByAsync(x => x.Id == It.IsAny <int>(), false));
            var actionResult = await _controller.GetAsync(1);

            Assert.NotNull(actionResult);
        }
Esempio n. 7
0
        public UserSettingsModel GetUserSettings(int userId)
        {
            UserSettingsModel result = null;

            using (var dataContext = this.dataContextFactory.Create())
            {
                var userSettings = dataContext.UserSettings.SingleOrDefault(x => x.UserID == userId);

                if (userSettings != null)
                {
                    result = new UserSettingsModel
                    {
                        UserID = userSettings.UserID,
                        Time   = userSettings.Time,
                        SendAdminNotification        = userSettings.SendAdminNotification,
                        SendChangedOrderNotification = userSettings.SendChangedOrderNotification,
                        SendWeeklyNotification       = userSettings.SendWeeklyNotification,
                        SendDailyNotification        = userSettings.SendDailyNotification
                    };
                }
            }
            return(result);
        }
        public ActionResult Index()
        {
            UserSettingsModel _SettingsModel = new UserSettingsModel();
            var currentUser = idb.Users.Find(User.Identity.GetUserId());

            _SettingsModel.Locations = repository.GetLocations().ToList();
            Location _Location = repository.GetLocations().Where(l => l.id == currentUser.LocationID).FirstOrDefault();

            _SettingsModel.LocationsId         = _Location.id;
            _SettingsModel.CurrentUserLocation = _Location.Name;
            _SettingsModel.ReceiveEmails       = currentUser.ReceiveEmails;
            _SettingsModel.FirstName           = currentUser.FirstName;
            _SettingsModel.LastName            = currentUser.LastName;

            if (currentUser.LocationID != null)
            {
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }

            return(View(_SettingsModel));
        }
Esempio n. 9
0
 public void Load()
 {
     try
     {
         string docPath = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
         string way     = docPath + "\\M2B\\ServiceViewer\\";
         if (Directory.Exists(way))
         {
             string file = way + "user.m2bs";
             if (File.Exists(file))
             {
                 StreamReader      sr   = File.OpenText(file);
                 string            data = sr.ReadToEnd();
                 UserSettingsModel temp = JsonConvert.DeserializeObject <UserSettingsModel>(data);
                 if (temp != null)
                 {
                     UserSettings = temp;
                 }
             }
         }
         CarStorage.Instance.LastCarNumbers = UserSettings.LastCarNumbers;
     }
     catch { }
 }
Esempio n. 10
0
        public async Task <bool> UpdateSettings(UserSettingsModel model)
        {
            var user = await _userManager.FindByIdAsync(model.UserId);

            if (user != null)
            {
                user.CaloriesTarget = model.CaloriesTarget;
                user.FirstName      = model.FirstName;
                user.LastName       = model.LastName;

                var updateResult = await _userManager.UpdateAsync(user);

                if (!updateResult.Succeeded)
                {
                    _errors.AddRange(updateResult.Errors.Select(x => x.Description).ToList());
                }

                return(updateResult.Succeeded);
            }

            _errors.Add("Bad Request: User doesn't exist!");

            return(false);
        }
Esempio n. 11
0
 private void SaveUserSettings(UserSettingsModel settings)
 {
     HttpContext.Session.Set("settings", settings);
 }
Esempio n. 12
0
 public Task <OperationResult> UpdateUserSettings([FromBody] UserSettingsModel model)
 {
     return(_accountService.UpdateUserSettings(model));
 }
Esempio n. 13
0
        private static UserSettingsModel GetUserSettingsFromJson(string json)
        {
            UserSettingsModel userSettings = JsonConvert.DeserializeObject <UserSettingsModel>(json);

            return(userSettings);
        }
Esempio n. 14
0
        public ActionResult Edit(UserSettingsModel settings)
        {
            if ( ModelState.IsValid )
            {
                UserRepository users = new UserRepository();
                users.ModifySettings( HttpContext.User.Identity.Name, settings );

                return RedirectToAction( "Index", "Home" );
            }

            return View( settings );
        }
Esempio n. 15
0
 public UserSettingsModel Post([FromBody] UserSettingsModel model)
 {
     _userSettingsService.EditSettings(_loggedInUser, model);
     return(_userSettingsService.GetSettings(_loggedInUser, model.UserId));
 }
Esempio n. 16
0
 public async Task ShowSettingsMenu(string chatId, SettingsKeyboardState state,
                                    SelectedOption option = default(SelectedOption), UserSettingsModel model = null, IEnumerable <LabelInfo> labels = null)
 {
     var keyboard = _settingsKeyboardFactory.CreateKeyboard(state, model, labels);
     var message  = SettingsMenuMessageBuilder(state, option, model);
     await _telegramMethods.SendMessage(chatId, message, ParseMode.Html, false, false, null, keyboard);
 }
Esempio n. 17
0
        public async Task <JwtSecurityToken> GetIdentityToken(List <Claim> claims, string tenant, string audience, DateTime?expiration)
        {
            // add iat claim
            var timeSinceEpoch = DateTime.UtcNow.ToEpochTime();

            claims.Add(new Claim("iat", timeSinceEpoch.ToString(), ClaimValueTypes.Integer));

            var userId = claims.First(t => t.Type == "sub").Value;

            // Create a userTenantInput for the purpose of finding the full tenant list associated with this user
            UserTenantInput tenantInput = new UserTenantInput
            {
                UserId = userId,
            };
            UserTenantListModel tenantsModel = await this.userTenantContainer.GetAllAsync(tenantInput);

            List <UserTenantModel> tenantList = tenantsModel.Models;

            // User did not specify the tenant to log into so get the default or last used
            if (string.IsNullOrEmpty(tenant))
            {
                // authState has no tenant, so we should use either the User's last used tenant, or the first tenant available to them
                // Create a UserSettingsInput for the purpose of finding the LastUsedTenant setting for this user
                this.logger.LogInformation("User did not specify Tenant so default/last used tenant is set.");
                UserSettingsInput settingsInput = new UserSettingsInput
                {
                    UserId     = userId,
                    SettingKey = "LastUsedTenant",
                };
                UserSettingsModel lastUsedSetting = await this.userSettingsContainer.GetAsync(settingsInput);

                // Has last used tenant and it is in the list
                if (lastUsedSetting != null && tenantList.Count(t => t.TenantId == lastUsedSetting.Value) > 0)
                {
                    tenant = lastUsedSetting.Value;
                }

                if (string.IsNullOrEmpty(tenant) && tenantList.Count > 0)
                {
                    tenant =
                        tenantList.First()
                        .TenantId;     // Set the tenant to the first tenant in the list of tenants for this user
                }
            }

            // If User not associated with Tenant then dont add claims return token without
            if (tenant != null)
            {
                UserTenantInput input = new UserTenantInput
                {
                    UserId = userId,
                    Tenant = tenant,
                };
                UserTenantModel tenantModel = await this.userTenantContainer.GetAsync(input);

                // Add Tenant
                claims.Add(new Claim("tenant", tenantModel.TenantId));

                // Add Roles
                tenantModel.RoleList.ForEach(role => claims.Add(new Claim("role", role)));

                // Settings Update LastUsedTenant
                UserSettingsInput settingsInput = new UserSettingsInput
                {
                    UserId     = claims.Where(c => c.Type == "sub").First().Value,
                    SettingKey = "LastUsedTenant",
                    Value      = tenant,
                };

                // Update if name is not the same
                await this.userSettingsContainer.UpdateAsync(settingsInput);

                if (tenantModel.Name != claims.Where(c => c.Type == "name").First().Value)
                {
                    input.Name = claims.Where(c => c.Type == "name").First().Value;
                    await this.userTenantContainer.UpdateAsync(input);
                }
            }

            DateTime expirationDateTime = expiration ?? DateTime.Now.AddDays(30);

            // add all tenants they have access to
            claims.AddRange(tenantList.Select(t => new Claim("available_tenants", t.TenantId)));

            // Token to String so you can use it in your client
            var token = this.MintToken(claims, audience, expirationDateTime);

            return(token);
        }
Esempio n. 18
0
 public IActionResult SaveSettings(UserSettingsModel userSettings)
 {
     SaveSetting(userSettings);
     return(R.Success.Result);
 }
Esempio n. 19
0
        public bool HandleGoogleNotifyMessage(GoogleNotifyMessage message)
        {
            bool result = true;

            if (message?.Message == null)
            {
                result = false;
            }
            else if (message.Subscription != BotInitializer.Instance.BotSettings.Subscription)
            {
                result = false;
            }

            if (result)
            {
                var decodedData = JsonConvert.DeserializeObject <EncodedMessageData>(Base64.DecodeUrlSafe(message.Message.Data));
                if (decodedData == null)
                {
                    result = false;
                }
                else
                {
                    LogMaker.Log(Logger, $"Received push notification from account {decodedData.Email} with historyId={decodedData.HistoryId}.", false);
                    UserSettingsModel userSettings = null;
                    try
                    {
                        var userModel = _dbWorker.FindUserByEmail(decodedData.Email);
                        if (userModel == null)
                        {
                            throw new DbDataStoreException(
                                      $"Can't find user data in database. User record with email {decodedData.Email} is absent in the database.");
                        }
                        userSettings = _dbWorker.FindUserSettings(userModel.UserId);
                        if (userSettings == null)
                        {
                            throw new DbDataStoreException(
                                      $"Can't find user settings data in database. User record with id {userModel.UserId} is absent in the database.");
                        }

                        var service = Methods.SearchServiceByUserId(userModel.UserId.ToString());
                        var query   = service.GmailService.Users.History.List("me");
                        query.HistoryTypes   = UsersResource.HistoryResource.ListRequest.HistoryTypesEnum.MessageAdded;
                        query.LabelId        = Label.Unread;
                        query.StartHistoryId = Convert.ToUInt64(userSettings.HistoryId);
                        var listRequest = query.Execute();
                        var historyList = listRequest.History?.ToList();
                        if (historyList != null)
                        {
                            var addedMessageCollection =
                                historyList.FindAll(h => h.MessagesAdded != null)
                                .SelectMany(m => m.MessagesAdded)
                                .ToList();

                            foreach (var addedMessage in addedMessageCollection)
                            {
                                var getRequest       = service.GmailService.Users.Messages.Get("me", addedMessage.Message.Id);
                                var messageResponse  = getRequest.Execute();
                                var formattedMessage = new FormattedMessage(messageResponse);

                                if (userSettings.IgnoreList.Any(ignoreModel => ignoreModel.Address == formattedMessage.From.Email))
                                {
                                    continue;
                                }

                                if (userSettings.UseWhitelist)
                                {
                                    if (!userSettings.Whitelist.Any(label => formattedMessage.LabelIds.Contains(label.LabelId)))
                                    {
                                        continue;
                                    }
                                }

                                if (userSettings.Blacklist.Any(label => formattedMessage.LabelIds.Contains(label.LabelId)))
                                {
                                    continue;
                                }

                                _botActions.ShowShortMessage(userModel.UserId.ToString(), formattedMessage);

                                if (userSettings.ReadAfterReceiving)
                                {
                                    Methods.ModifyMessageLabels(service, formattedMessage.MessageId, null, new List <string> {
                                        "UNREAD"
                                    });
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        LogMaker.Log(Logger, ex);
                    }
                    finally
                    {
                        if (userSettings != null)
                        {
                            userSettings.HistoryId = long.Parse(decodedData.HistoryId);
                            _dbWorker.UpdateUserSettingsRecord(userSettings);
                        }
                    }
                }
            }

            if (!result)
            {
                LogMaker.Log(Logger, $"Unauthorized attempt to notify.", false);
            }
            return(result);
        }
Esempio n. 20
0
 public PermissionsKeyboard(UserSettingsModel settings)
 {
     Settings = settings;
 }
Esempio n. 21
0
 public AdditionalMenuKeyboard(UserSettingsModel settings)
 {
     settings.NullInspect(nameof(settings));
     Settings = settings;
 }
Esempio n. 22
0
        public ActionResult Index()
        {
            UserSettingsModel model = new UserSettingsModel();

            return(View(model));
        }
 public UserSettingsModel Add(UserSettingsModel model)
 {
     model.Id = userSettingsList.Max(p => p.Id) + 1;
     userSettingsList.Add(model);
     return(model);
 }
Esempio n. 24
0
 public RangeManagementViewModel(PersistanceManager persistanceManager)
 {
     _userSettingsModel = persistanceManager.UserSettingsModel;
 }
Esempio n. 25
0
        public ActionResult Edit()
        {
            UserRepository users = new UserRepository();
            UserModel user = users.GetByUsername( HttpContext.User.Identity.Name );

            UserSettingsModel settings = new UserSettingsModel
            {
                DateOfBirth = user.DateOfBirth,
                About = user.About,
                NotifyComment = user.NotifyComment,
                NotifyPhoto = user.NotifyPhoto,
                NotifySubscription = user.NotifySubscription
            };

            return View( settings );
        }
Esempio n. 26
0
        static ReferencesResolverExtensionPackage()
        {
            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);

            DefaultUserSettings = new UserSettingsModel()
            {
                CommandModels = new ResolveReferencesCommandModel[]
                {
                    new ResolveReferencesCommandModel("WPF Current Telerik Binaries",
                                                      new ReplaceReferencesOptionModel[]
                    {
                        new ReplaceReferencesOptionModel()
                        {
                            CopyFolderPath = @"C:\Work\WPF_Scrum\Current\Binaries\WPF\",
                        },
                    },
                                                      new ReferenceModel[]
                    {
                        // No specific items to add
                    }),
                    new ResolveReferencesCommandModel("WPF Development Telerik Binaries",
                                                      new ReplaceReferencesOptionModel[]
                    {
                        new ReplaceReferencesOptionModel()
                        {
                            CopyFolderPath = @"C:\Work\WPF_Scrum\Development\Binaries\WPF\",
                        },
                    },
                                                      new ReferenceModel[]
                    {
                        // No specific items to add
                    }),
                    new ResolveReferencesCommandModel("WPF Release Telerik Binaries",
                                                      new ReplaceReferencesOptionModel[]
                    {
                        new ReplaceReferencesOptionModel()
                        {
                            CopyFolderPath = @"C:\Work\WPF_Scrum\Release\Binaries\WPF\",
                        },
                    },
                                                      new ReferenceModel[]
                    {
                        // No specific items to add
                    }),
                    new ResolveReferencesCommandModel("Silverlight Current Telerik Binaries",
                                                      new ReplaceReferencesOptionModel[]
                    {
                        new ReplaceReferencesOptionModel()
                        {
                            CopyFolderPath = @"C:\Work\WPF_Scrum\Current\Binaries\Silverlight\",
                        },
                    },
                                                      new ReferenceModel[]
                    {
                        // No specific items to add
                    }),
                    new ResolveReferencesCommandModel("Silverlight Development Telerik Binaries",
                                                      new ReplaceReferencesOptionModel[]
                    {
                        new ReplaceReferencesOptionModel()
                        {
                            CopyFolderPath = @"C:\Work\WPF_Scrum\Development\Binaries\Silverlight\",
                        },
                    },
                                                      new ReferenceModel[]
                    {
                        // No specific items to add
                    }),
                    new ResolveReferencesCommandModel("Silverlight Release Telerik Binaries",
                                                      new ReplaceReferencesOptionModel[]
                    {
                        new ReplaceReferencesOptionModel()
                        {
                            CopyFolderPath = @"C:\Work\WPF_Scrum\Release\Binaries\Silverlight\",
                        },
                    },
                                                      new ReferenceModel[]
                    {
                        // No specific items to add
                    }),
                },

                SelectedIndex = 0
            };

            DefaultUserSettingsJson = ConvertUserSettingToJson(DefaultUserSettings);
        }
 public void EditSettings(LoginModel loggedInUser, UserSettingsModel request)
 {
     CheckPermission(loggedInUser, request.UserId, "Can't edit someone else settings.");
     _userSettingsRepository.EditSettings(request);
 }
Esempio n. 28
0
 internal RestUserSettings(RestDiscordClient client, UserSettingsModel model) : base(client)
 {
     Update(model);
 }
Esempio n. 29
0
        /// <summary>
        /// 1= Success, 0= Failed, 4= User not Found
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public APIReturnModel SaveUserSettings(UserSettingsModel model)
        {
            try
            {
                UserSetting usersettings = new UserSetting();
                bool        isupdate     = false;
                //Check user id is provided
                if (!string.IsNullOrEmpty(model.Id))
                {
                    //Check user id exists in db
                    SystemUser chkexisting = Db.SystemUsers.FirstOrDefault(d => d.Id == model.Id && !d.IsArchived);
                    if (chkexisting != null)
                    {
                        usersettings = Db.UserSettings.FirstOrDefault(d => d.Id == model.Id);

                        if (usersettings == null)
                        {
                            usersettings = new UserSetting
                            {
                                Id = model.Id
                            };
                        }
                        else
                        {
                            isupdate = true;
                        }

                        usersettings.EmailNewNotification          = model.EmailNewNotification;
                        usersettings.EmailNotification             = model.EmailNotification;
                        usersettings.NotificationMuteNewAccount    = model.NotificationMuteNewAccount;
                        usersettings.NotificationMuteWhoDontFollow = model.NotificationMuteWhoDontFollow;
                        usersettings.NotificationMuteYouDontFollow = model.NotificationMuteYouDontFollow;
                        usersettings.PrivacyPhotoTagging           = model.PrivacyPhotoTagging;
                        usersettings.PrivacyTweetLocation          = model.PrivacyTweetLocation;
                        usersettings.PrivacyTweetPrivacy           = model.PrivacyTweetPrivacy;

                        usersettings.IsArchived = false;

                        if (!isupdate)
                        {
                            Db.UserSettings.Add(usersettings);
                        }
                        Db.SaveChanges();

                        return(new APIReturnModel {
                            Status = 1, Value = usersettings.Id
                        });
                    }
                    else
                    {
                        return new APIReturnModel {
                                   Status = 4
                        }
                    };
                }
                else
                {
                    return new APIReturnModel {
                               Status = 4
                    }
                };
            }
            catch
            {
                return(new APIReturnModel {
                    Status = 0
                });
            }
        }
Esempio n. 30
0
 public async Task ShowSettingsMenu(string chatId, UserSettingsModel settings)
 {
     var keyboard = _settingsKeyboardFactory.CreateKeyboard(SettingsKeyboardState.MainMenu, settings);
     var message  = SettingsMenuMessageBuilder(SettingsKeyboardState.MainMenu);
     await _telegramMethods.SendMessage(chatId, message, ParseMode.Html, false, false, null, keyboard);
 }
Esempio n. 31
0
 public ActionResult KullanıcıGüncellePost(UserSettingsModel updatedModel)
 {
     _userService.UpdateUser(updatedModel.User);
     TempData["Success"] = "Kullanıcı başarıyla güncellendi";
     return(RedirectToAction("Index"));
 }
Esempio n. 32
0
        private string SettingsMenuMessageBuilder(SettingsKeyboardState state, SelectedOption option = default(SelectedOption),
                                                  UserSettingsModel userSettings = null, string editableLableId = null)
        {
            if (userSettings == null && state.EqualsAny(
                    SettingsKeyboardState.LabelsMenu,
                    SettingsKeyboardState.IgnoreMenu,
                    SettingsKeyboardState.WhiteListMenu,
                    SettingsKeyboardState.BlackListMenu))
            {
                throw new InvalidOperationException($"{nameof(userSettings)} must be not null if {nameof(state)} equals {state}.");
            }

            StringBuilder message = new StringBuilder();

            switch (state)
            {
            case SettingsKeyboardState.MainMenu:
                switch (option)
                {
                case SelectedOption.Option9:         //about button
                    message.AppendLine($"<b>{_settings.BotName}</b>");
                    message.AppendLine();
                    message.AppendLine();
                    message.AppendLine($"Bot version: {_settings.BotVersion}");
                    message.AppendLine("Developed by Igor 'CoffeeJelly' Salzhenitsin");
                    message.AppendLine("Contact emails:");
                    message.AppendLine("<code>[email protected]</code>");
                    message.AppendLine("<code>[email protected]</code>");
                    message.AppendLine();
                    message.AppendLine();
                    message.AppendLine("2017");
                    break;

                default:
                    message.Append("<b>Main Settings Menu</b>");
                    break;
                }
                break;

            case SettingsKeyboardState.LabelsMenu:
                switch (option)
                {
                default:
                    message.AppendLine("<b>Labels Menu</b>");
                    message.AppendLine();
                    message.Append(!userSettings.UseWhitelist
                                ? "Choose <b>Whitelist</b> to specify the email labels that will be allowed. "
                                   + "Incoming email without at least one of the selected labels will not be displayed in the Telegram chat."
                                : "Choose <b>Blacklist</b> to specify the email labels that will be blocked."
                                   + "Incoming email with at least one of the selected labels will not be displayed in the Telegram chat.");
                    break;
                }
                break;

            case SettingsKeyboardState.EditLabelsMenu:
                message.AppendLine("<b>User Defined Editable Labels:</b>");
                message.AppendLine();
                break;

            case SettingsKeyboardState.WhiteListMenu:
                message.AppendLine("<b>Whitelist</b>");
                message.AppendLine();
                message.AppendLine(!userSettings.UseWhitelist
                        ? "If you want to use whitelist click \"Use whitelist mode\" button."
                        : "Click the button to add it to (or remove from) the whitelist.");
                break;

            case SettingsKeyboardState.BlackListMenu:
                message.AppendLine("<b>Blacklist</b>");
                message.AppendLine();
                message.AppendLine(userSettings.UseWhitelist
                        ? "If you want to use blacklist click \"Use blacklist mode\" button."
                        : "Click the button to add it to (or remove from) the blacklist.");
                break;

            case SettingsKeyboardState.IgnoreMenu:
                switch (option)
                {
                case SelectedOption.Option1:
                    message.AppendLine(userSettings.IgnoreList?.Count == 0
                                ? "Your ignore list is empty."
                                : $"You have {userSettings.IgnoreList?.Count} email(s) ignored:");
                    userSettings.IgnoreList?.IndexEach((email, i) =>
                    {
                        message.AppendLine($"{i + 1}. {email.Address}");
                    });
                    break;

                default:
                    message.AppendLine("<b>Ignore Control Menu</b>");
                    message.AppendLine();
                    message.AppendLine(
                        "To stop receiving notifications about new emails from a specific email address, " +
                        "add it to the ignore list.");
                    message.AppendLine("To add or remove an email from the ignore list, click the button and type the email address.");
                    message.AppendLine();
                    message.AppendLine($"{Emoji.INFO_SIGN} You can type the displayed sequence number to remove the email from the ignore list.");
                    break;
                }
                break;

            case SettingsKeyboardState.AdditionalMenu:
                message.Append("<b>Main Settings Menu</b>");
                break;

            case SettingsKeyboardState.PermissionsMenu:
                message.AppendLine("<b>Permissions Menu</b>");
                message.AppendLine();
                message.AppendLine("You can change or revoke the bot permissions to your Gmail account here.");
                break;

            case SettingsKeyboardState.LabelActionsMenu:
                message.AppendLine($"<b>Edit label with id {editableLableId}:</b>");
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(state), state, null);
            }

            return(message.ToString());
        }
Esempio n. 33
0
        /// <summary>
        /// Mocked value
        /// </summary>
        public Task <UserSettingsModel> Settings()
        {
            var userSettings = new UserSettingsModel();

            return(Task.FromResult(userSettings));
        }