public dynamic GetAllSubCategoryListWithPrefrence(JObject Obj) { SubIndustryListFilters filter = Obj.ToObject <SubIndustryListFilters>(); int total = 0; SubIndustryVal re = new SubIndustryVal(); var prefrence = _prefenceService.GetPreference(filter.currentUserId); re.SubIndustryData = _adminService.GetAllSubCategoryList(filter.limit, filter.offset, filter.order, filter.sort, filter.Preference, filter.IndustryId, filter.UserType, out total); foreach (var item in re.SubIndustryData) { foreach (var pref in prefrence) { if (item.SubIndustryName == pref.Preference) { item.Preference = true; } } } var result = new { total = total, rows = re.SubIndustryData, }; return(result); }
public CustomEasyCardClick() { InitializeComponent(); PreferenceServie = Locator.Instance.Resolve <IPreferenceService>(); IsChecked = PreferenceServie.GetPreference(PreferenceKey.Dungeon_01_Tr_01, false); CheckPref(false); }
public override async Task <SaveCustomerPreferencesResponse> Handle(SaveCustomerPreferencesRequest request, CancellationToken cancellationToken) { var optedInPreferences = request.CustomerPreferences .Where(customerPreference => customerPreference.Value == true); var optedOutPreferences = request.CustomerPreferences .Where(customerPreference => customerPreference.Value == false); var invalidPreferences = new List <string>(); var preferences = await _cacheProvider.GetPreferences(cancellationToken); var customerPreferences = await _customerPreferenceService .GetCustomerPreferences(request.CustomerId, request.FromDate, cancellationToken); var savedCustomerPreferences = new List <CustomerPreference>(); foreach (var preference in request.CustomerPreferences) { Preference foundPreference; if ((foundPreference = _preferenceService.GetPreference(preferences, preference.Key)) == null) { invalidPreferences.Add(preference.Key); continue; } var customerPreference = _customerPreferenceService.GetCustomerPreference(customerPreferences, foundPreference.Id); if (customerPreference == null) { customerPreference = new CustomerPreference { CustomerId = request.CustomerId, PreferenceId = foundPreference.Id } } ; customerPreference.OptInDate = request.FromDate; customerPreference.NextCheckInDate = request.NextCheckInDate; savedCustomerPreferences.Add(await _customerPreferenceService .Save(customerPreference, false, false, cancellationToken)); } if (savedCustomerPreferences.Count > 0) { await _customerPreferenceService .CommitChanges(cancellationToken); } return(Response.Success <SaveCustomerPreferencesResponse>(savedCustomerPreferences.ToArray(), model => { model.InalidPreferences = invalidPreferences.ToArray(); model.TotalOptedIn = optedInPreferences.Count(); model.TotalOptedOut = optedOutPreferences.Count(); })); } }
public override async Task <SavePreferenceResponse> Handle(SavePreferenceRequest request, CancellationToken cancellationToken) { var isNewCategory = false; var preferences = await _cacheProvider.GetPreferences(cancellationToken); var preference = _preferenceService.GetPreference(preferences, request.Name); if (preference != null) { return(Response.Failed <SavePreferenceResponse>(new ValidationFailure(nameof(request.Name), "Preference already exists"))); } var categories = await _cacheProvider.GetCategories(cancellationToken); var category = string.IsNullOrWhiteSpace(request.CategoryName) ? _categoryService.GetCategory(categories, request.CategoryId) : _categoryService.GetCategory(categories, request.CategoryName); preference = new Preference { Name = request.Name, }; if (category == null) { if (string.IsNullOrWhiteSpace(request.CategoryName)) { return(Response.Failed <SavePreferenceResponse>( new ValidationFailure(nameof(request.CategoryId), "Unable to find category"))); } category = await _categoryService.Save(new Category { Name = request.CategoryName }, false, false, cancellationToken); preference.Category = category; isNewCategory = true; } else { preference.CategoryId = category.Id; } preference = await _preferenceService.Save(preference, true, true, cancellationToken); return(Response.Success <SavePreferenceResponse>(preference, configure => { configure.IsNewCategory = isNewCategory; configure.CategoryId = category.Id; })); }
public List <smPreference> GetPreference(int userId) { return(_preferenceService.GetPreference(userId)); }