예제 #1
0
        //
        // GET: /Manage/Index
        public async Task <ActionResult> Index(ManageMessageId?message)
        {
            //get the notification preference
            string          userId = User.Identity.GetUserId();
            ApplicationUser user   = db.Users
                                     .Include(u => u.NotificationPreference)
                                     .Where(u => u.Id == userId)
                                     .FirstOrDefault();
            NotificationPreference notificationPreference = user.NotificationPreference;

            ViewBag.StatusMessage =
                message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed."
                : message == ManageMessageId.SetPasswordSuccess ? "Your password has been set."
                : message == ManageMessageId.SetTwoFactorSuccess ? "Your two-factor authentication provider has been set."
                : message == ManageMessageId.Error ? "An error has occurred."
                : message == ManageMessageId.AddPhoneSuccess ? "Your phone number was added."
                : message == ManageMessageId.RemovePhoneSuccess ? "Your phone number was removed."
                : "";

            var model = new IndexViewModel
            {
                HasPassword            = HasPassword(),
                PhoneNumber            = await UserManager.GetPhoneNumberAsync(userId),
                TwoFactor              = await UserManager.GetTwoFactorEnabledAsync(userId),
                Logins                 = await UserManager.GetLoginsAsync(userId),
                BrowserRemembered      = await AuthenticationManager.TwoFactorBrowserRememberedAsync(userId),
                NotificationPreference = notificationPreference
            };

            return(View(model));
        }
        protected override void ExecuteInternal()
        {
            eBay.Service.Core.Sdk.ApiContext apiContext = this.ApiContext;
            eBay.Service.Call.GetNotificationPreferencesCall apiCall = new eBay.Service.Call.GetNotificationPreferencesCall(apiContext);

            apiCall.GetNotificationPreferences(this.NotificationRoleCode);

            apiCall.PreferenceLevel = NotificationRoleCodeType.User;

            apiCall.Execute();

            if (apiCall.ApiResponse.ApplicationDeliveryPreferences != null)
            {
                Console.WriteLine(apiCall.ApplicationDeliveryPreferences.ApplicationEnable.ToString());
                Console.WriteLine(apiCall.ApplicationDeliveryPreferences.ApplicationURL);
            }

            this.NotificationPreferences = new List <NotificationPreference>();

            for (int i = 0; i <= 96; i++)
            {
                NotificationEventTypeCodeType code = (NotificationEventTypeCodeType)i;

                if (code == NotificationEventTypeCodeType.None ||
                    code == NotificationEventTypeCodeType.CustomCode)
                {
                    continue;
                }
                if (code == NotificationEventTypeCodeType.MyMessagesAlert ||
                    code == NotificationEventTypeCodeType.MyMessagesAlertHeader)
                {
                    continue;                     // Depreciated
                }
                // FeedbackForSeller == When we recieve feedback.
                //
                NotificationPreference item = new NotificationPreference(code);
                this.NotificationPreferences.Add(item);
            }

            this.NotificationPreferences.Sort
            (
                delegate(NotificationPreference x1, NotificationPreference x2)
            {
                return(x1.EventType.ToString().CompareTo(x2.EventType.ToString()));
            }
            );

            foreach (NotificationEnableType item in apiCall.ApiResponse.UserDeliveryPreferenceArray)
            {
                var preference = this.NotificationPreferences.Single(x => x.EventType == item.EventType);

                preference.Enabled = (item.EventEnable == EnableCodeType.Enable);
                preference.Dirty   = false;
            }
        }
예제 #3
0
        public ResponseData <AirGapSetting> UpdateNotificationPreference(string value, string applianceId)
        {
            try
            {
                _notificationPreferenceService.RemoveNotificationPreferenceByApplianceId(Convert.ToInt64(applianceId));
                if (!string.IsNullOrEmpty(value))
                {
                    if (value.IndexOf(',') != -1)
                    {
                        var arr = value.Split(',');
                        foreach (var item in arr)
                        {
                            var    temp        = item.Split('-');
                            string accountId   = temp[0];
                            string timerTypeId = temp[1];
                            NotificationPreference notificationPreference = new NotificationPreference()
                            {
                                AccountId   = Convert.ToInt64(accountId),
                                ApplianceId = Convert.ToInt64(applianceId),
                                EventTypeId = Convert.ToInt64(timerTypeId),
                            };
                            _notificationPreferenceService.Insert(notificationPreference);
                        }
                    }
                    else
                    {
                        var    arr         = value.Split('-');
                        string accountId   = arr[0];
                        string timerTypeId = arr[1];
                        NotificationPreference notificationPreference = new NotificationPreference()
                        {
                            AccountId   = Convert.ToInt64(accountId),
                            ApplianceId = Convert.ToInt64(applianceId),
                            EventTypeId = Convert.ToInt64(timerTypeId),
                        };
                        _notificationPreferenceService.Insert(notificationPreference);
                    }
                }

                var response = new ResponseData <AirGapSetting>();
                response.Message = ResponseMessage.Success;
                response.Status  = ResponseStatus.Success.ToString();
                return(response);
            }
            catch (Exception ex)
            {
                var response = new ResponseData <AirGapSetting>();
                response.Message = ex.Message;
                response.Status  = ResponseStatus.Error.ToString();
                return(response);
            }
        }
예제 #4
0
        public async Task <IActionResult> SetUserNotificationPreferences([FromBody] NotificationPreference newPreference)
        {
            using (var db = ArangoDatabase.CreateWithSetting())
            {
                var user = await(from u in db.Query <User>()
                                 where u.Key == HttpContext.User.Identity.Name
                                 select u).FirstOrDefaultAsync();
                if (user == null)
                {
                    return(NotFound());
                }

                user.NotificationPreference = newPreference;
                await db.UpdateByIdAsync <User>(user.Key, user);

                return(Ok());
            }
        }
예제 #5
0
        public UserBulider AddNotificationPreferences(NotificationPreference notificationPreference)
        {
            _notificationPreferences.Add(notificationPreference);

            return(this);
        }
예제 #6
0
        protected override void Seed(BandMate.Models.ApplicationDbContext context)
        {
            //Seed the subscription types
            SubscriptionType monthlySubscription = new SubscriptionType();

            monthlySubscription.Name  = "Monthly Subscription";
            monthlySubscription.Price = 9.99d;

            SubscriptionType annualSubscription = new SubscriptionType();

            annualSubscription.Name  = "Annual Subscription";
            annualSubscription.Price = 108.00d;

            context.SubscriptionTypes.Add(monthlySubscription);
            context.SubscriptionTypes.Add(annualSubscription);

            context.SaveChanges();

            //Seed the product types
            ProductType standardProductType = new ProductType();

            standardProductType.Name = "Standard Product";

            ProductType garmentProductType = new ProductType();

            garmentProductType.Name = "Garment";

            context.ProductTypes.Add(standardProductType);
            context.ProductTypes.Add(garmentProductType);

            context.SaveChanges();

            ////Seed the sizes
            //Size small = new Size();
            //small.Name = "Small";
            //small.Abbreviation = "S";

            //Size medium = new Size();
            //medium.Name = "Medium";
            //medium.Abbreviation = "M";

            //Size large = new Size();
            //large.Name = "Large";
            //large.Abbreviation = "L";

            //Size xLarge = new Size();
            //xLarge.Name = "X-Large";
            //xLarge.Abbreviation = "XL";

            //Size xxLarge = new Size();
            //xxLarge.Name = "XX-Large";
            //xxLarge.Abbreviation = "XXL";

            //context.Sizes.Add(small);
            //context.Sizes.Add(medium);
            //context.Sizes.Add(large);
            //context.Sizes.Add(xLarge);
            //context.Sizes.Add(xxLarge);

            //context.SaveChanges();

            //Seed notification preferences
            NotificationPreference emailPreference = new NotificationPreference();

            emailPreference.Name = "Email";

            NotificationPreference textPreference = new NotificationPreference();

            textPreference.Name = "Text";

            context.NotificationPreferences.Add(emailPreference);
            context.NotificationPreferences.Add(textPreference);

            context.SaveChanges();

            //Seed States table with all US States from CSV
            string seedFile = "~/CSV/SeedData/";//states.csv removed from end of seedFile
            string filePath = GetMapPath(seedFile);

            bool fileExists = File.Exists(filePath + "states.csv");

            if (fileExists)
            {
                List <State> states = new List <State>();
                using (TextFieldParser parser = new TextFieldParser(filePath + "states.csv"))
                {
                    parser.TextFieldType = FieldType.Delimited;
                    parser.SetDelimiters(",");
                    State state;
                    while (!parser.EndOfData)
                    {
                        string[] fields = parser.ReadFields();
                        if (fields.Any(x => x.Length == 0))
                        {
                            Console.WriteLine("We found an empty value in your CSV. Please check your file and try again.\nPress any key to return to main menu.");
                            Console.ReadKey(true);
                        }
                        state              = new State();
                        state.Name         = fields[0];
                        state.Abbreviation = fields[1];
                        states.Add(state);
                    }
                }
                context.States.AddOrUpdate(c => c.Abbreviation, states.ToArray());
                context.SaveChanges();
            }
        }
예제 #7
0
 public NotificationPreference Insert(NotificationPreference notificationPreference)
 {
     return(repoNotificationPreference.Insert(notificationPreference));
 }