public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View view = inflater.Inflate(Resource.Layout.categories, container, false);
            InputMethodManager imm = (InputMethodManager)Context.GetSystemService(Context.InputMethodService);

            categoriesRecicleView = view.FindViewById <RecyclerView>(Resource.Id.categoriesRecicleView);
            searchEditText        = view.FindViewById <EditText>(Resource.Id.searchEditText);
            var cancelButton  = view.FindViewById <Button>(Resource.Id.cancelButton);
            var accountButton = view.FindViewById <ImageButton>(Resource.Id.accountButton);

            listSearchRecycleView = view.FindViewById <RecyclerView>(Resource.Id.listSearchRecycleView);
            var basketButton = view.FindViewById <ImageButton>(Resource.Id.imageButton);

            fillCategories();
            fillSearch();

            searchEditText.SetFocusable(ViewFocusability.NotFocusable);

            searchEditText.AfterTextChanged += (sender, args) =>
            {
                if (!args.Equals(""))
                {
                    filter(args.ToString());
                }
            };

            searchEditText.Click += delegate
            {
                searchEditText.SetFocusable(ViewFocusability.Focusable);
                cancelButton.Visibility          = ViewStates.Visible;
                listSearchRecycleView.Visibility = ViewStates.Visible;
                imm.ToggleSoftInput(InputMethodManager.ShowForced, 0);
            };
            cancelButton.Click += delegate
            {
                searchEditText.SetFocusable(ViewFocusability.Focusable);
                cancelButton.Visibility = ViewStates.Invisible;
                searchEditText.Text     = "";
                view.ClearFocus();
                imm.HideSoftInputFromWindow(searchEditText.WindowToken, 0);
                listSearchRecycleView.Visibility = ViewStates.Invisible;
            };

            accountButton.Click += delegate
            {
                AccountActivity fragment = new AccountActivity();
                this.FragmentManager.BeginTransaction().Replace(Resource.Id.main_container, fragment, "account").AddToBackStack(null).Commit();
                listSearchRecycleView.Visibility = ViewStates.Invisible;
            };

            basketButton.Click += delegate
            {
                BasketActivity fragment = new BasketActivity();
                this.FragmentManager.BeginTransaction().Replace(Resource.Id.main_container, fragment, "basket").AddToBackStack(null).Commit();
                listSearchRecycleView.Visibility = ViewStates.Invisible;
            };


            return(view);
        }
        public void ProcessResults_ForWebhooks_HandlesSingleResult()
        {
            var accActReqProc = new AccountActivityRequestProcessor <AccountActivity>
            {
                BaseUrl = "https://api.twitter.com/1.1/",
                Type    = AccountActivityType.Webhooks
            };

            List <AccountActivity> accActs = accActReqProc.ProcessResults(WebhooksResponse);

            Assert.IsNotNull(accActs?.SingleOrDefault());

            AccountActivity accAct = accActs.First();

            Assert.IsNotNull(accAct);
            WebhooksValue webhooksVal = accAct.WebhooksValue;

            Assert.IsNotNull(webhooksVal);
            Webhook[] webhooks = webhooksVal.Webhooks;
            Assert.IsNotNull(webhooks);
            Assert.AreEqual(1, webhooks.Length);
            Webhook webhook = webhooks.First();

            Assert.IsNotNull(webhook);
            Assert.AreEqual("920835776169910272", webhook.ID);
            Assert.AreEqual("https://accountactivitydemo.azurewebsites.net/api/accountactivity", webhook.Url);
            Assert.IsTrue(webhook.Valid);
            Assert.AreEqual("2017-10-19 02:15:32 +0000", webhook.CreatedTimestamp);
        }
        public async Task <AccountActivity> CreateAccountActivityAsync(AccountActivity model)
        {
            var create = _db.AccountActivities.Add(model).Entity;
            await _db.SaveChangesAsync();

            return(create);
        }
        // Add your own data access methods here.  If you wish to
        // expose your public method to a WCF service, marked them with
        // the attribute [NCPublish], and another T4 template will generate your service contract

        /// <summary>
        /// This method inserts account activity details in db
        /// </summary>
        /// <param name="pkActivityID">pkActivityID</param>
        /// <param name="currID">currID</param>
        /// <param name="newAccType">newAccType</param>
        /// <param name="pkClientAccID">pkClientAccID</param>
        public void InsertAccountActivityDetails(int pkActivityID, int currID, string newAccType, int?pkClientAccID)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var accActRepo =
                        new AccountActivityRepository(new EFRepository <AccountActivity>(), unitOfWork);

                    AccountActivity newActivity = new AccountActivity();
                    newActivity.FK_AccActivityTypeID = (int)AccountActivityType.NewAccountCreation;
                    newActivity.Currency             = currID;
                    newActivity.AccountType          = newAccType;
                    newActivity.FK_UserActivityID    = pkActivityID;
                    newActivity.FK_ClientAccountID   = pkClientAccID;

                    accActRepo.Add(newActivity);
                    accActRepo.Save();
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
Ejemplo n.º 5
0
        public async Task DeleteAccountActivitySubscriptionAsync_WithWebhookID_ReturnsCreatedAccountActivity()
        {
            const ulong WebhookID = 1;
            var         ctx       = InitializeTwitterContext();

            AccountActivity accAct = await ctx.DeleteAccountActivitySubscriptionAsync(WebhookID);

            Assert.IsNotNull(accAct);
        }
Ejemplo n.º 6
0
        public async Task AddAccountActivitySubscriptionAsync_WithWebhookParameter_PopulatesInputParametersInResponse()
        {
            const ulong WebhookID = 1;
            var         ctx       = InitializeTwitterContext();

            AccountActivity accAct = await ctx.AddAccountActivitySubscriptionAsync(WebhookID);

            Assert.IsNotNull(accAct);
            Assert.AreEqual(WebhookID, accAct.WebhookID);
        }
Ejemplo n.º 7
0
        public async Task AddAccountActivityWebhookAsync_WithUrlParameter_PopulatesInputParametersInResponse()
        {
            const string Url = "https://www.example.com/api/accountactivity";
            var          ctx = InitializeTwitterContext();

            AccountActivity accAct = await ctx.AddAccountActivityWebhookAsync(Url);

            Assert.IsNotNull(accAct);
            Assert.AreEqual(Url, accAct.Url);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Sends email to logged-in user's email.
        /// Please make sure <paramref name="localizedMailBodyContents"/> dictionary parameter taken from <see cref="PrepareMailBodyDictionary(string[])"/>.
        /// </summary>
        /// <param name="localizedMailBodyContents"></param>
        /// <param name="urlPath"></param>
        /// <param name="accountActivity"></param>
        /// <param name="newInfo"> Could be new phone number or new email. </param>
        /// <param name="username"></param>
        /// <returns></returns>
        private async Task SendActivityMailAsync(Dictionary <string, string> localizedMailBodyContents,
                                                 string urlPath,
                                                 AccountActivity accountActivity,
                                                 string newInfo  = null,
                                                 string username = null)
        {
            var uName = username ?? _userName;

            var user = await _userRepository.GetFirstOrDefaultAsync(a => a.UserName == _userName).ConfigureAwait(false)
                       ?? throw new MilvaUserFriendlyException(MilvaException.CannotFindEntity);

            if (string.IsNullOrWhiteSpace(user?.Email))
            {
                throw new MilvaUserFriendlyException("IdentityInvalidEmail");
            }

            string token = "";

            switch (accountActivity)
            {
            case AccountActivity.EmailVerification:
                token = await _userManager.GenerateEmailConfirmationTokenAsync(user).ConfigureAwait(false);

                break;

            case AccountActivity.EmailChange:
                token = await _userManager.GenerateChangeEmailTokenAsync(user, newInfo).ConfigureAwait(false);

                break;

            case AccountActivity.PasswordReset:
                token = await _userManager.GeneratePasswordResetTokenAsync(user).ConfigureAwait(false);

                break;

            case AccountActivity.PhoneNumberChange:
                token = await _userManager.GenerateChangePhoneNumberTokenAsync(user, newInfo).ConfigureAwait(false);

                break;
            }

            var confirmationUrl = $"{GlobalConstants.ApplicationSiteUrl}/{urlPath}?userName={username ?? _userName}&token={token}";

            var htmlContent = await File.ReadAllTextAsync(Path.Combine(GlobalConstants.RootPath, "StaticFiles", "HTML", "mail_content.html")).ConfigureAwait(false);

            foreach (var localizedMailBodyContent in localizedMailBodyContents)
            {
                htmlContent = htmlContent.Replace(localizedMailBodyContent.Key, localizedMailBodyContent.Value);
            }

            htmlContent = htmlContent.Replace("~BodyButtonLink", confirmationUrl);

            await _milvaMailSender.MilvaSendMailAsync(user.Email, localizedMailBodyContents["~MailTitle"], htmlContent, true);
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> YeniIsOlustur(Job job, IFormFile Image)
        {
            // İş Veren Bakiyesinden 1 TL Dusme
            int  userId    = Convert.ToInt32(HttpContext.Session.GetString("SessionUserId"));
            User user      = _userService.GetUserById(userId);
            int  userMoney = Convert.ToInt32(user.Money);

            if (userMoney < 1)
            {
                TempData["AddErrorMessage"] = "Hesabınızda Yeni Bir İlan Oluşturmak İçin Yeterli Bakiye Yoktur.";
                return(View());
            }
            userMoney  = userMoney - 1;
            user.Money = userMoney.ToString();
            _userService.Update(user);

            // Hesap Hareketlerine Bu Islemi Yazdirma
            AccountActivity accountActivity = new AccountActivity();

            accountActivity.Title       = "İş İlanı Oluşturma Gideri";
            accountActivity.Description = "İş İlanı Oluşturulduğu İçin Hesabınızdan 1 TL Alınmıştır.";
            accountActivity.CreatedDate = DateTime.Now;
            accountActivity.IsIncrease  = false;
            accountActivity.UserId      = userId;
            accountActivity.Money       = "1";
            _accountActivityService.Add(accountActivity);

            // Yeni Is İlanı Olusturma
            if (job.Title.Length == 0 || job.Description.Length == 0)
            {
                TempData["AddErrorMessage"] = "Lütfen Boş Alanları Doldurunuz.";
                return(View());
            }

            job.CreatedDate = DateTime.Now;
            job.ViewCount   = "0";
            job.UserId      = userId;
            job.IsConfirm   = false;
            job.IsCompleted = false;

            // Is Ilani Resim Kaydetme
            string guidImageName = Guid.NewGuid().ToString();

            if (await KurnazFileUploader.UploadFile(Image, guidImageName, "ImagesJob") == true)
            {
                job.Photo = guidImageName + Image.FileName;
            }

            _jobService.Add(job);

            TempData["AddSuccessMessage"] = "Oluşturduğunuz İlan Başarılı Bir Şekilde Sisteme Gönderildi. İnceleme İşlemlerinin Ardından Tarafınıza Bilgi Mesajı Gönderilecektir.";
            return(RedirectToAction("UyeProfil", "Uye"));
        }
Ejemplo n.º 10
0
        public async Task AddAccountActivitySubscriptionAsync_WithWebhookID_ReturnsCreatedAccountActivity()
        {
            const ulong WebhookID = 1;
            var         ctx       = InitializeTwitterContext();

            AccountActivity accAct = await ctx.AddAccountActivitySubscriptionAsync(WebhookID);

            Assert.IsNotNull(accAct);
            SubscriptionValue subsVal = accAct.SubscriptionValue;

            Assert.IsNotNull(subsVal);
            Assert.IsTrue(subsVal.IsSubscribed);
        }
        public void ProcessResults_WithWebhooksQuery_ReplacesInputParams()
        {
            var accActReqProc = new AccountActivityRequestProcessor <AccountActivity>
            {
                BaseUrl = "https://api.twitter.com/1.1/",
                Type    = AccountActivityType.Webhooks
            };

            List <AccountActivity> accActList = accActReqProc.ProcessResults(WebhooksResponse);

            AccountActivity accAct = accActList.First();

            Assert.AreEqual(AccountActivityType.Webhooks, accAct.Type);
        }
Ejemplo n.º 12
0
 /* Isveren Hesap Hareketi Detay Sayfasi */
 public IActionResult HesapHareketDetay(int Id)
 {
     int developerId = Convert.ToInt32(HttpContext.Session.GetString("SessionDeveloperId"));
     AccountActivity accountActivity = _accountActivityService.GetAccountActivityById(Id);
     if (accountActivity == null)
     {
         return RedirectToAction("Hata", "Uye");
     }
     if (accountActivity.DeveloperId != developerId)
     {
         return RedirectToAction("Hata", "Uye");
     }
     return View(accountActivity);
 }
        public void Test_BillingMessageMachine_SendMessage(string printJobName, string activityTypeCode, string issueSystemCode)
        {
            // arrange
            var printJobService = MockRepository.GenerateMock <IPrintJobService>();
            var logger          = MockRepository.GenerateMock <IMessageLogger>();
            var harness         = new InMemoryTestHarness();
            var machine         = new BillingMessageMachine(printJobService, logger);
            var saga            = harness.StateMachineSaga <BillingMessageState, BillingMessageMachine>(machine);

            printJobService
            .Expect(p => p.GetPolicyTransactions("A123456", "58f31946b12b441892cd798973aab87e"))
            .Return(Task.FromResult <string>(this.transactionStatusValidXml.ToString()));

            printJobService
            .Expect(p => p.PostPrintJobRequest(Arg.Is("A123456"), Arg.Is("00"), Arg.Is("1"), Arg.Is(printJobName), Arg <string> .Is.Anything, Arg.Is("58f31946b12b441892cd798973aab87e")))
            .Return(Task.FromResult <string>("printed!"));

            var accountActivity = new AccountActivity
            {
                ActivityTypeCode = activityTypeCode,
                Policy           = new Policy
                {
                    PolicyNumber    = "A123456",
                    Mod             = "00",
                    IssueSystemCode = issueSystemCode
                }
            };

            // act
            harness.Start().Wait();

            harness.Bus.Publish <IAccountActivity>(accountActivity).Wait();

            // wait for the publish to do its thing, the Wait() above doesn't guarantee much.
            var receivedMessage = harness.Consumed.Select <IAccountActivity>().FirstOrDefault();

            // assert
            printJobService.VerifyAllExpectations();
            logger.VerifyAllExpectations();

            receivedMessage.Exception.ShouldBeNull();
            harness.Consumed.Count().ShouldEqual(1);
            harness.Published.Count().ShouldEqual(1);
            harness.Sent.Count().ShouldEqual(0);
            saga.Consumed.Count().ShouldEqual(1);

            // cleanup
            harness.Stop().Wait();
        }
        static async Task DeleteSubscriptionAsync(TwitterContext twitterCtx)
        {
            ulong webhookID = GetWebhook();

            try
            {
                AccountActivity accAct = await twitterCtx.DeleteAccountActivitySubscriptionAsync(webhookID);

                Console.WriteLine("Subscription deleted.");
            }
            catch (TwitterQueryException tqEx) // Twitter returns a 3XX when it can't delete, which throws
            {
                Console.WriteLine($"Unable to delete subscription: {tqEx.Message}");
            }
        }
        static async Task SendChallengeResponseCheckAsync(TwitterContext twitterCtx)
        {
            ulong webhookID = GetWebhook();

            try
            {
                AccountActivity accAct = await twitterCtx.SendAccountActivityCrcAsync(webhookID);

                Console.WriteLine("Challenge response check succeeded.");
            }
            catch (TwitterQueryException tqEx) // Twitter returns a 3XX when it can't delete, which throws
            {
                Console.WriteLine($"Challenge response check failed: {tqEx.Message}");
            }
        }
        public async Task <IActionResult> Logout([FromBody] LogoutForm logout)
        {
            var logoutActivity = new AccountActivity
            {
                AccountId = logout.AccountId,
                IpAddress = _httpContext.Connection.RemoteIpAddress.ToString(),
                Operation = "Выход из системы",
                At        = DateTime.Now
            };

            await _db.CreateAccountActivityAsync(logoutActivity);

            await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);

            return(Ok(new { loggedOut = true }));
        }
        public void Test_BillingMessageMachine_SendMessage_InvalidCode(string printJobName, string activityTypeCode, string issueSystemCode)
        {
            // arrange
            var printJobService = MockRepository.GenerateMock <IPrintJobService>();
            var logger          = MockRepository.GenerateMock <IMessageLogger>();
            var harness         = new InMemoryTestHarness();
            var machine         = new BillingMessageMachine(printJobService, logger);
            var saga            = harness.StateMachineSaga <BillingMessageState, BillingMessageMachine>(machine);

            var accountActivity = new AccountActivity
            {
                ActivityTypeCode = activityTypeCode,
                Policy           = new Policy
                {
                    PolicyNumber    = "A123456",
                    Mod             = "00",
                    IssueSystemCode = issueSystemCode
                }
            };

            // act
            harness.Start().Wait();

            harness.Bus.Publish <IAccountActivity>(accountActivity).Wait();

            // wait for the publish to do its thing, the Wait() above doesn't guarantee much.
            var receivedMessage = harness.Consumed.Select <IAccountActivity>().FirstOrDefault();

            // assert
            var        message     = logger.GetArgumentsForCallsMadeOn <IMessageLogger>(x => x.Log(Arg <Log> .Is.Anything, Arg <string> .Is.Null, Arg <string> .Is.Null, Arg <string> .Is.Null));
            Log        argumentLog = (Log)message[0][0];
            LogMessage logMessage  = argumentLog.Messages[0];

            Assert.AreEqual(logMessage.Category, Constants.Logging.CATEGORY);
            Assert.AreEqual(logMessage.Severity, SeverityType.Information);

            printJobService.AssertWasNotCalled(p => p.GetPolicyTransactions(Arg <string> .Is.Anything, Arg <string> .Is.Anything));
            printJobService.VerifyAllExpectations();
            receivedMessage.Exception.ShouldBeNull();
            harness.Consumed.Count().ShouldEqual(1);
            harness.Published.Count().ShouldEqual(1);
            harness.Sent.Count().ShouldEqual(0);
            saga.Consumed.Count().ShouldEqual(1);

            // cleanup
            harness.Stop().Wait();
        }
        public void ProcessResults_WithSubscriptionsQuery_ReplacesInputParams()
        {
            const ulong WebhookID = 4;

            var accActReqProc = new AccountActivityRequestProcessor <AccountActivity>
            {
                BaseUrl   = "https://api.twitter.com/1.1/",
                Type      = AccountActivityType.Subscriptions,
                WebhookID = WebhookID
            };

            List <AccountActivity> accActs = accActReqProc.ProcessResults("");

            AccountActivity accAct = accActs.First();

            Assert.AreEqual(WebhookID, accAct.WebhookID);
        }
        public void ProcessResults_ForSubscriptions_HandlesResult()
        {
            var accActReqProc = new AccountActivityRequestProcessor <AccountActivity>
            {
                BaseUrl   = "https://api.twitter.com/1.1/",
                Type      = AccountActivityType.Subscriptions,
                WebhookID = 1
            };

            List <AccountActivity> accActs = accActReqProc.ProcessResults("");

            AccountActivity accAct = accActs?.SingleOrDefault();

            Assert.IsNotNull(accAct);
            SubscriptionValue subsVal = accAct.SubscriptionValue;

            Assert.IsNotNull(subsVal);
            Assert.IsTrue(subsVal.IsSubscribed);
        }
        static async Task AddWebhookAsync(TwitterContext twitterCtx)
        {
            try
            {
                Console.Write("What is the Webhook URL? ");
                string url = Console.ReadLine();

                AccountActivity accAct = await twitterCtx.AddAccountActivityWebhookAsync(url);

                Webhook webhook = accAct.WebhooksValue.Webhooks.SingleOrDefault();
                Console.WriteLine(
                    $"Webhook for '{webhook.Url}' " +
                    $"added with ID: {webhook.ID}, " +
                    $"created at {webhook.CreatedTimestamp}");
            }
            catch (TwitterQueryException tqe)
            {
                Console.WriteLine(tqe.Message);
            }
        }
Ejemplo n.º 21
0
        public async Task AddAccountActivityWebhookAsync_WithUrlParameter_ReturnsCreatedAccountActivity()
        {
            const string Url = "https://www.example.com/api/accountactivity";
            var          ctx = InitializeTwitterContext();

            AccountActivity accAct = await ctx.AddAccountActivityWebhookAsync(Url);

            Assert.IsNotNull(accAct);
            WebhooksValue accActVal = accAct.WebhooksValue;

            Assert.IsNotNull(accActVal);
            Webhook[] webhooks = accActVal.Webhooks;
            Assert.IsNotNull(webhooks);
            Assert.AreEqual(1, webhooks.Length);
            Webhook webhook = webhooks[0];

            Assert.IsNotNull(webhook);
            Assert.AreEqual("921246280768151552", webhook.ID);
            Assert.AreEqual("https://accountactivitydemo.azurewebsites.net/api/accountactivity", webhook.Url);
            Assert.IsTrue(webhook.Valid);
            Assert.AreEqual("2017-10-20 05:26:44 +0000", webhook.CreatedTimestamp);
        }
Ejemplo n.º 22
0
        protected override OpResult _Store(AccountActivity _obj)
        {
            if (_obj == null)
            {
                return(OpResult.NotifyStoreAction(OpResult.ResultStatus.ObjectIsNull, _obj, "AccountActivity object cannot be created as it is null"));
            }

            if (Exists(_obj))
            {
                ExecuteNonQuery(GetQuery_UpdateQuery(_obj));
                return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Updated, _obj));
            }

            ExecuteNonQuery(GetQuery_InsertQuery(_obj));
            if (_obj.AccountActivityID == null)
            {
                _obj.AccountActivityID = DbMgr.GetLastInsertID();
            }
            _obj.FromDb = true;

            return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Created, _obj));
        }
Ejemplo n.º 23
0
        public ActionResult RemovePaymentFromInvoiceJSON(string clientID, string paymentID, string invoiceID, string invoiceNumber)
        {
            int id = 0;

            if (!int.TryParse(clientID, out id))
            {
                id = 0;
            }
            string          message         = "";
            AccountActivity accountActivity = null;

            try
            {
                int paymentIDInt = int.Parse(paymentID);
                int invoiceIDInt = int.Parse(invoiceID);
                Clients.RemovePaymentFromInvoice(paymentIDInt, invoiceIDInt);
                int BillingContactID = Clients.GetPrimaryBillingContactIDFromClient(id).Value;
                if (BillingContactID != 0)
                {
                    accountActivity = BillingStatements.GetAccountActivityForAnInvoiceIDAndPaymentID(BillingContactID, 0, invoiceIDInt, paymentIDInt);
                    return(new JsonResult {
                        Data = new { success = true, accountActivity = accountActivity, paymentID = paymentID, invoiceID = invoiceID, invoiceNumber = invoiceNumber }
                    });
                }
                else
                {
                    message = "Request processed. However there is no primary billing contact for the client.";
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }
            return(new JsonResult {
                Data = new { success = false, message = message, paymentID = paymentID, invoiceID = invoiceID, invoiceNumber = invoiceNumber }
            });
        }
Ejemplo n.º 24
0
 public void Add(AccountActivity entity)
 {
     Repository.Add(entity);
 }
 public void Delete(AccountActivity accountActivity)
 {
     _accountActivityDal.Delete(accountActivity);
 }
 public void Add(AccountActivity accountActivity)
 {
     _accountActivityDal.Add(accountActivity);
 }
        public async Task <IActionResult> Login([FromBody] UserCredentials cred)
        {
            if (cred == null || String.IsNullOrEmpty(cred.UserName) || String.IsNullOrEmpty(cred.Password))
            {
                return(BadRequest(new ApiError("401", "Не удалось авторизоваться", "Не введены логин и/или пароль")));
            }

            var account = await _db.GetAccountAsync(cred.UserName);

            if (account == null)
            {
                return(NotFound(new ApiError("401", "Не удалось авторизоваться", "Пользователь с таким именем не найден")));
            }

            if (cred.Password != account.Password)
            {
                return(BadRequest(new ApiError("401", "Не удалось авторизоваться", "Введен неправильный пароль")));
            }


            var claims = new List <Claim>
            {
                new Claim(ClaimTypes.Sid, account.Id.ToString()),
                new Claim(ClaimsIdentity.DefaultNameClaimType, account.UserName),
                new Claim(ClaimsIdentity.DefaultRoleClaimType, account.Role),
                new Claim(ClaimTypes.Role, account.Role),
                new Claim(ClaimTypes.Uri, account.AvatarUri)
            };

            if (account.Person != null)
            {
                claims.Add(new Claim(ClaimTypes.PrimarySid, account.Person.Id.ToString()));
                claims.Add(new Claim(ClaimTypes.GivenName, account.Person.ShortName));
                claims.Add(new Claim(ClaimTypes.Email, account.Person.Email));
                claims.Add(new Claim(ClaimTypes.MobilePhone, account.Person.Phone));
            }

            var id = new ClaimsIdentity(
                claims,
                CookieAuthenticationDefaults.AuthenticationScheme,
                ClaimsIdentity.DefaultNameClaimType,
                ClaimsIdentity.DefaultRoleClaimType
                );

            try
            {
                await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(id));

                var loginActivity = new AccountActivity
                {
                    AccountId = account.Id,
                    IpAddress = _httpContext.Connection.RemoteIpAddress.ToString(),
                    Operation = "Вход в систему",
                    At        = DateTime.Now
                };

                await _db.CreateAccountActivityAsync(loginActivity);
            }
            catch (Exception ex)
            {
                return(BadRequest(new ApiError("403", "Не удалось авторизоваться", ex.Message)));
            }

            return(Ok());
        }
Ejemplo n.º 28
0
 public void Delete(AccountActivity entity)
 {
     Repository.Delete(entity);
 }
 public void Update(AccountActivity accountActivity)
 {
     _accountActivityDal.Update(accountActivity);
 }
Ejemplo n.º 30
0
        /// <summary>
        /// BuildCustomerAccountStatement - Populates customerAccountProfile.Statements
        /// and customerAccountProfile.TotalCurrentBalance
        /// </summary>
        /// <param name="accountNumber9">9 digit account number</param>
        /// <param name="accountNumber">full account number</param>
        /// <param name="customerAccountProfile">Customer account profile object</param>
        /// <returns><void></returns>
        private void BuildCustomerAccountStatement(string accountNumber9, CustomerAccountNumber accountNumber, CustomerAccountProfile customerAccountProfile)
        {
            //Get Statements CurrentAmount, EnrolledInEasyPay, EnrolledInStopPaperBill
            Account account = new Account();

            //get a data access obj to coxprod_commerce
            //DalBillNotification dalBillNotification = new DalBillNotification();

            //// setup adapter and fill account object.
            AccountAdapter adapter = new AccountAdapter(accountNumber, _userName, _siteId, _siteCode);

            adapter.Fill(account);

            double totalCurrentBalance     = 0.00;
            double monthlyRecurringRevenue = 0.0;

            if (account.Statements != null && account.Statements.Count > 0)
            {
                customerAccountProfile.Statements = new List <Cox.BusinessObjects.CustomerAccount.Statement>();

                for (int j = 0; j < account.Statements.Count; j++)
                {
                    bool enrolledInStopPaperBill = false;
                    //bool enrolledInEmailBillReminder = false;

                    if (account.Statements[j].BillingOption == eBillingOption.StopPaper)
                    {
                        enrolledInStopPaperBill = true;
                    }
                    if (account.Statements[j].BillingOption == eBillingOption.WebStopPaper)
                    {
                        enrolledInStopPaperBill = true;
                    }
                    //enrolledInEmailBillReminder = dalBillNotification.GetEnrolledInEmailBillReminder(accountNumber9, _siteId, account.Statements[j].AccountNumber16.Substring(4, 4), account.Statements[j].StatementCode);

                    // Call GetMonthlyServiceAmount
                    DalCustomerAccount dalCustomerAccount = new DalCustomerAccount();
                    CustomerAccountProfileSchema.CustomerMonthlyServiceAmountDataTable customerMonthlyServiceAmountDT = dalCustomerAccount.GetMonthlyServiceAmount(_siteId, accountNumber9);

                    if (customerMonthlyServiceAmountDT != null && customerMonthlyServiceAmountDT.Rows.Count > 0)
                    {
                        customerAccountProfile.TotalMonthlyRecurringRevenue = customerMonthlyServiceAmountDT[0].Total_Monthly_SVC_Amount;

                        for (int i = 0; i < customerMonthlyServiceAmountDT.Count; ++i)
                        {
                            int statementCode   = 0;
                            int statementCodeDT = 0;
                            statementCode   = int.Parse(account.Statements[j].StatementCode);
                            statementCodeDT = int.Parse(customerMonthlyServiceAmountDT[i].Statement_Code);
                            if (statementCode == statementCodeDT)
                            {
                                monthlyRecurringRevenue = customerMonthlyServiceAmountDT[i].StatementCD_Monthly_SVC_Amount;
                            }
                        }
                    }

                    //[05-02-2009] Start Changes for reflecting AR amounts for Q-Matic

                    //customerAccountProfile.Statements.Add(new Cox.BusinessObjects.CustomerAccount.Statement(account.Statements[j].StatementCode, account.Statements[j].AccountNumber16, monthlyRecurringRevenue, account.Statements[j].CurrentBalance, account.Statements[j].EasyPayFlag, enrolledInStopPaperBill, enrolledInEmailBillReminder));

                    customerAccountProfile.Statements.Add(new Cox.BusinessObjects.CustomerAccount.Statement(account.Statements[j].StatementCode,
                                                                                                            account.Statements[j].AccountNumber16, monthlyRecurringRevenue, account.Statements[j].CurrentBalance,
                                                                                                            account.Statements[j].EasyPayFlag, enrolledInStopPaperBill,
                                                                                                            account.Statements[j].AR1To30Amount, account.Statements[j].AR31To60Amount, account.Statements[j].AR61To90Amount, account.Statements[j].AR91To120Amount));

                    //[05-02-2009] Start Changes for reflecting AR amounts for Q-Matic

                    totalCurrentBalance += account.Statements[j].CurrentBalance;
                }
                customerAccountProfile.TotalCurrentBalance = totalCurrentBalance;
            }

            //[23-02-2009] Start Changes for improving performance of CustomerAccount service

            AccountActivity accountActivity = new AccountActivity(_userName, _siteId);

            accountActivity.SetAllowOnlineOrderingFlag(ref account);

            if (account.AllowOnlineOrdering)
            {
                customerAccountProfile.OnlineOrderDelinquentBalance = false;
            }
            else
            {
                customerAccountProfile.OnlineOrderDelinquentBalance = true;
            }

            if (account.OnlineOrderingOptOut != 0)
            {
                customerAccountProfile.OnlineOrderBlock = true;
            }
            else
            {
                customerAccountProfile.OnlineOrderBlock = false;
            }

            //[23-02-2009] End Changes for improving performance of CustomerAccount service
        }