public AccountManagementWindow()
 {
     InitializeComponent();
     accountModel             = new AccountManagementViewModel();
     accountModel.currentUser = (Users)Application.Current.Properties["CurrentUser"];
     this.DataContext         = accountModel;
 }
        public async Task<ActionResult> AddPayment(PaymentDetailsViewModel model)
        {
            if (!ModelState.IsValid)
            {
                var data = await mediator.SendAsync(new GetAccountManagementData(model.NotificationId));
                var accountManagementViewModel = new AccountManagementViewModel(data);
                accountManagementViewModel.RefundViewModel = await GetNewRefundDetailsViewModel(model.NotificationId);
                accountManagementViewModel.PaymentViewModel = model;
                accountManagementViewModel.ShowPaymentDetails = true;

                return View("Index", accountManagementViewModel);
            }

            if (model.PaymentMethod != PaymentMethod.Cheque)
            {
                model.Receipt = "NA";
            }

            var paymentData = new NotificationTransactionData
            {
                Date = model.PaymentDate.AsDateTime().Value,
                NotificationId = model.NotificationId,
                Credit = Convert.ToDecimal(model.PaymentAmount),
                PaymentMethod = model.PaymentMethod,
                ReceiptNumber = model.Receipt,
                Comments = model.Comments
            };

            await mediator.SendAsync(new AddNotificationTransaction(paymentData));

            return RedirectToAction("Index", "AccountManagement");
        }
        public async Task <ActionResult> AddRefund(RefundDetailsViewModel model)
        {
            if (!ModelState.IsValid)
            {
                var data = await mediator.SendAsync(new GetAccountManagementData(model.NotificationId));

                var accountManagementViewModel = new AccountManagementViewModel(data);
                accountManagementViewModel.PaymentViewModel = new PaymentDetailsViewModel {
                    NotificationId = model.NotificationId
                };
                accountManagementViewModel.RefundViewModel   = model;
                accountManagementViewModel.ShowRefundDetails = true;

                return(View("Index", accountManagementViewModel));
            }

            var refundData = new NotificationTransactionData
            {
                Date           = model.RefundDate.AsDateTime().Value,
                NotificationId = model.NotificationId,
                Debit          = Convert.ToDecimal(model.RefundAmount),
                Comments       = model.RefundComments.Trim(),
                ReceiptNumber  = "NA"
            };

            await mediator.SendAsync(new AddNotificationTransaction(refundData));

            return(RedirectToAction("index", "AccountManagement", new { id = model.NotificationId }));
        }
Beispiel #4
0
        public ActionResult UpdateAccountData(AccountManagementViewModel amvm)
        {
            AccountManagementServiceClient amsc = new AccountManagementServiceClient();

            amsc.updateAccData(amvm.Account);
            return(RedirectToAction("IndexAccount"));
        }
        public async Task <ActionResult> AddPayment(PaymentDetailsViewModel model)
        {
            if (!ModelState.IsValid)
            {
                var data = await mediator.SendAsync(new GetAccountManagementData(model.NotificationId));

                var accountManagementViewModel = new AccountManagementViewModel(data);
                accountManagementViewModel.RefundViewModel = await GetNewRefundDetailsViewModel(model.NotificationId);

                accountManagementViewModel.PaymentViewModel   = model;
                accountManagementViewModel.ShowPaymentDetails = true;

                return(View("Index", accountManagementViewModel));
            }

            if (model.PaymentMethod != PaymentMethod.Cheque)
            {
                model.Receipt = "NA";
            }

            var paymentData = new NotificationTransactionData
            {
                Date           = model.PaymentDate.AsDateTime().Value,
                NotificationId = model.NotificationId,
                Credit         = Convert.ToDecimal(model.PaymentAmount),
                PaymentMethod  = model.PaymentMethod,
                ReceiptNumber  = model.Receipt,
                Comments       = model.PaymentComments.Trim()
            };

            await mediator.SendAsync(new AddNotificationTransaction(paymentData));

            return(RedirectToAction("Index", "AccountManagement"));
        }
        public ActionResult CreateAccounts(AccountManagementViewModel model, int id)
        {
            var cookie = Request.Cookies["token"];

            if (cookie == null)
            {
                return(RedirectToAction("Login", "Account"));
            }
            var accessToken = cookie.Value;
            var httpClient  = new HttpClient();

            httpClient.DefaultRequestHeaders.Authorization =
                new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", accessToken);

            var parameters = new List <System.Collections.Generic.KeyValuePair <string, string> >();

            parameters.Add(new KeyValuePair <string, string>("Name", model.Name));
            parameters.Add(new KeyValuePair <string, string>("Balance", model.Balance));
            parameters.Add(new KeyValuePair <string, string>("HouseHoldId", model.Id.ToString()));

            var formEncodedValues = new FormUrlEncodedContent(parameters);

            var result =
                httpClient.PostAsync("http://localhost:54111/api/accounts/Postaccounts/", formEncodedValues).Result;

            if (result.StatusCode == System.Net.HttpStatusCode.OK)
            {
                var jsonString = result.Content.ReadAsStringAsync().Result;
                var houseHolds = JsonConvert
                                 .DeserializeObject <AccountManagementViewModel>(jsonString);
                return(View(houseHolds));
            }
            return(View());
        }
Beispiel #7
0
        public ActionResult AddaccountToRole(AccountManagementViewModel amvm)
        {
            AccountManagementServiceClient amsc = new AccountManagementServiceClient();

            amsc.addAccToRole(amvm.AccRoleMapp);
            return(RedirectToAction("IndexAccount"));
        }
Beispiel #8
0
        public ActionResult ShowAccountData(string id)
        {
            AccountManagementServiceClient amsc = new AccountManagementServiceClient();
            AccountManagementViewModel     amvm = new AccountManagementViewModel();

            amvm.Account = amsc.findAcc(id);
            return(View("ShowAccountData", amvm));
        }
 public AccountManagementPage()
 {
     InitializeComponent();
     BindingContext = new AccountManagementViewModel();
     //if the account is a customer, display the add address button
     if ((int)Application.Current.Properties["accountLevelID"] == 3)
     {
         add_addr.IsVisible = true;
     }
 }
        public async Task<ActionResult> Index(Guid id)
        {
            var data = await mediator.SendAsync(new GetImportNotificationAccountOverview(id));
            var accountManagementViewModel = new AccountManagementViewModel(data);
            var canDeleteTransaction = await authorizationService.AuthorizeActivity(typeof(DeleteTransaction));

            accountManagementViewModel.PaymentViewModel = new PaymentDetailsViewModel();
            accountManagementViewModel.RefundViewModel = await GetNewRefundDetailsViewModel(id);
            accountManagementViewModel.CanDeleteTransaction = canDeleteTransaction;

            return View(accountManagementViewModel);
        }
        public async Task<ActionResult> Index(Guid id)
        {
            var data = await mediator.SendAsync(new GetAccountManagementData(id));
            var model = new AccountManagementViewModel(data);
            var canDeleteTransaction = await authorizationService.AuthorizeActivity(typeof(DeleteTransactionController));

            model.PaymentViewModel = new PaymentDetailsViewModel{ NotificationId = id };
            model.RefundViewModel = await GetNewRefundDetailsViewModel(id);
            model.CanDeleteTransaction = canDeleteTransaction;

            return View(model);
        }
        public async Task <ActionResult> Index(Guid id, AccountManagementViewModel model, int?commentId)
        {
            if (commentId != null)
            {
                if (string.IsNullOrEmpty(model.TableData[commentId.GetValueOrDefault()].Comments))
                {
                    return(RedirectToAction("IndexWithError", "AccountManagement", new { id = id, commentId = commentId }));
                }
                var result = await mediator.SendAsync(new UpdateExportNotificationAssementComments(model.TableData[commentId.GetValueOrDefault()].TransactionId, model.TableData[commentId.GetValueOrDefault()].Comments));
            }

            return(RedirectToAction("index", "AccountManagement", new { id = id }));
        }
        public async Task <ActionResult> Index(Guid id)
        {
            var data = await mediator.SendAsync(new GetImportNotificationAccountOverview(id));

            var accountManagementViewModel = new AccountManagementViewModel(data);
            var canDeleteTransaction       = await authorizationService.AuthorizeActivity(typeof(DeleteTransaction));

            accountManagementViewModel.PaymentViewModel = new PaymentDetailsViewModel();
            accountManagementViewModel.RefundViewModel  = await GetNewRefundDetailsViewModel(id);

            accountManagementViewModel.CanDeleteTransaction = canDeleteTransaction;

            return(View(accountManagementViewModel));
        }
        public async Task <ActionResult> EditProfile(AccountManagementViewModel model)
        {
            if (User.IsInRole("DemoAccount"))
            {
                RedirectToAction("Index", "Manage");
            }
            var user = UserManager.FindById(model.UserInfo.Id);

            user.FirstName = model.UserInfo.FirstName;
            user.LastName  = model.UserInfo.LastName;
            var updateResult = await UserManager.UpdateAsync(user);

            return(RedirectToAction("Index"));
        }
        //
        // GET: /Manage/Index
        public async Task <ActionResult> Index(ManageMessageId?message)
        {
            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 userId     = User.Identity.GetUserId();
            var userLogins = await UserManager.GetLoginsAsync(User.Identity.GetUserId());

            var otherLogins = AuthenticationManager.GetExternalAuthenticationTypes().Where(auth => userLogins.All(ul => auth.AuthenticationType != ul.LoginProvider)).ToList();
            AccountManagementViewModel model = new AccountManagementViewModel();

            model.HasPassword = HasPassword();
            model.PhoneNumber = await UserManager.GetPhoneNumberAsync(userId);

            model.TwoFactor = await UserManager.GetTwoFactorEnabledAsync(userId);

            model.Logins = await UserManager.GetLoginsAsync(userId);

            model.BrowserRemembered = await AuthenticationManager.TwoFactorBrowserRememberedAsync(userId);

            model.CurrentLogins = userLogins;
            model.OtherLogins   = otherLogins;
            model.UserInfo      = db.Users.AsNoTracking().FirstOrDefault(u => u.Id == userId);
            //model.UserTickets = model.UserInfo.Tickets.OrderByDescending(m => m.Created).ToList();
            model.UserTickets     = db.Tickets.AsNoTracking().Where(t => (t.AssignedUserId == userId) && t.IsArchived == false).ToList();
            model.UserComments    = db.TicketComments.AsNoTracking().OrderByDescending(c => c.Created).ToList();
            model.UserAttachments = db.TicketAttachments.AsNoTracking().OrderByDescending(a => a.Created).ToList();
            foreach (var role in model.UserInfo.Roles)
            {
                model.UserRoles.Add(db.Roles.First(r => r.Id == role.RoleId).Name);
            }
            ViewBag.StatusMessage =
                message == ManageMessageId.RemoveLoginSuccess ? "The external login was removed."
                : message == ManageMessageId.Error ? "An error has occurred."
                : "";
            var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());

            if (user == null)
            {
                return(View("Error"));
            }
            ViewBag.ShowRemoveButton = user.PasswordHash != null || userLogins.Count > 1;
            return(View(model));
        }
Beispiel #16
0
        //
        // GET: /Manage/Index
        public async Task <ActionResult> Index(ManageMessageId?message)
        {
            ApplicationDbContext db = new ApplicationDbContext();

            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 userId     = User.Identity.GetUserId();
            var userLogins = await UserManager.GetLoginsAsync(User.Identity.GetUserId());

            var otherLogins = AuthenticationManager.GetExternalAuthenticationTypes().Where(auth => userLogins.All(ul => auth.AuthenticationType != ul.LoginProvider)).ToList();
            AccountManagementViewModel model = new AccountManagementViewModel();

            model.HasPassword = HasPassword();
            model.PhoneNumber = await UserManager.GetPhoneNumberAsync(userId);

            model.TwoFactor = await UserManager.GetTwoFactorEnabledAsync(userId);

            model.Logins = await UserManager.GetLoginsAsync(userId);

            model.BrowserRemembered = await AuthenticationManager.TwoFactorBrowserRememberedAsync(userId);

            model.CurrentLogins = userLogins;
            model.OtherLogins   = otherLogins;
            //model.HouseholdId = db.Users.Find(User.Identity.GetUserId()).HouseholdId;
            model.UserInfo    = db.Users.AsNoTracking().FirstOrDefault(u => u.Id == userId);
            model.Invitations = db.Invitations.Where(i => i.InviteeEmail == model.UserInfo.Email).ToList();
            //foreach (var tx in model.UserInfo.Transactions) {
            //    model.Transactions.Add(tx);
            //}
            ViewBag.StatusMessage =
                message == ManageMessageId.RemoveLoginSuccess ? "The external login was removed."
                : message == ManageMessageId.Error ? "An error has occurred."
                : "";
            var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());

            if (user == null)
            {
                return(View("Error"));
            }
            ViewBag.ShowRemoveButton = user.PasswordHash != null || userLogins.Count > 1;
            return(View(model));
        }
        public async Task <ActionResult> Index(Guid id)
        {
            var data = await mediator.SendAsync(new GetAccountManagementData(id));

            var model = new AccountManagementViewModel(data);
            var canDeleteTransaction = await authorizationService.AuthorizeActivity(typeof(DeleteTransactionController));

            model.PaymentViewModel = new PaymentDetailsViewModel {
                NotificationId = id
            };
            model.RefundViewModel = await GetNewRefundDetailsViewModel(id);

            model.CanDeleteTransaction = canDeleteTransaction;

            return(View(model));
        }
        public async Task <ActionResult> IndexWithError(Guid id, int commentId)
        {
            var data = await mediator.SendAsync(new GetImportNotificationAccountOverview(id));

            var accountManagementViewModel = new AccountManagementViewModel(data);
            var canDeleteTransaction       = await authorizationService.AuthorizeActivity(typeof(DeleteTransaction));

            accountManagementViewModel.PaymentViewModel = new PaymentDetailsViewModel();
            accountManagementViewModel.RefundViewModel  = await GetNewRefundDetailsViewModel(id);

            accountManagementViewModel.CanDeleteTransaction = canDeleteTransaction;

            accountManagementViewModel.Transactions[commentId].Comments = string.Empty;
            accountManagementViewModel.ErrorCommentId = commentId;
            accountManagementViewModel.CommentError   = "Enter a comment";
            ModelState.AddModelError("CommentError", "Enter a comment");

            return(View("index", accountManagementViewModel));
        }
        public async Task<ActionResult> AddRefund(RefundDetailsViewModel model)
        {
            if (!ModelState.IsValid)
            {
                var data = await mediator.SendAsync(new GetImportNotificationAccountOverview(model.NotificationId));
                var accountManagementViewModel = new AccountManagementViewModel(data);
                accountManagementViewModel.PaymentViewModel = new PaymentDetailsViewModel();
                accountManagementViewModel.RefundViewModel = model;
                accountManagementViewModel.ShowRefundDetails = true;

                return View("Index", accountManagementViewModel);
            }

            var refundData = new AddNotificationRefund(model.NotificationId, Convert.ToDecimal(model.RefundAmount),
                model.RefundDate.AsDateTime().Value, model.RefundComments);

            await mediator.SendAsync(refundData);

            return RedirectToAction("index", "AccountManagement", new { id = model.NotificationId });
        }
        public ActionResult Register()
        {
            AccountManagementViewModel mymodel = new AccountManagementViewModel();
            var error        = (String)TempData["DeleteError"];
            var confirmation = (string)TempData["DelConfirmation"];

            if (!String.IsNullOrEmpty(error))
            {
                ModelState.AddModelError("Deletion", error);
                TempData.Remove("DeleteError");
            }
            else if (!string.IsNullOrEmpty(confirmation))
            {
                ViewBag.DelConfirmation = confirmation;
                confirmation            = "";
            }
            var currentUser = User.Identity.GetUserId();

            mymodel.TeamMembers = UserManager.Users.Where(x => x.teamLead.Id == currentUser).ToList();
            return(View(mymodel));
        }
        public async Task <ActionResult> AddRefund(RefundDetailsViewModel model)
        {
            if (!ModelState.IsValid)
            {
                var data = await mediator.SendAsync(new GetImportNotificationAccountOverview(model.NotificationId));

                var accountManagementViewModel = new AccountManagementViewModel(data);
                accountManagementViewModel.PaymentViewModel  = new PaymentDetailsViewModel();
                accountManagementViewModel.RefundViewModel   = model;
                accountManagementViewModel.ShowRefundDetails = true;

                return(View("Index", accountManagementViewModel));
            }

            var refundData = new AddNotificationRefund(model.NotificationId, Convert.ToDecimal(model.RefundAmount),
                                                       model.RefundDate.AsDateTime().Value, model.RefundComments.Trim());

            await mediator.SendAsync(refundData);

            return(RedirectToAction("index", "AccountManagement", new { id = model.NotificationId }));
        }
        public async Task <ActionResult> Register(AccountManagementViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (UserManager.FindByEmail(model.Email) == null)
                {
                    var user = new ApplicationUser {
                        UserName = model.Email, Email = model.Email, teamLead = UserManager.FindById(User.Identity.GetUserId())
                    };
                    var symbolStr    = "@$.,!%*?&";
                    var RandPassword = Membership.GeneratePassword(20, 5) + new Random().Next(9).ToString() + symbolStr[new Random().Next(8)];
                    var result       = await UserManager.CreateAsync(user, RandPassword);

                    if (result.Succeeded)
                    {
                        string EmailCode = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);

                        string InvCode = await UserManager.GenerateUserTokenAsync("Invite", user.Id);

                        var InviteUrl = Url.Action("AcceptInvite", "Account", new { userId = user.Id, InviteToken = InvCode, EmailConf = EmailCode }, Request.Url.Scheme);
                        await UserManager.SendEmailAsync(user.Id,
                                                         "Invitation", "Hello,<br><br>You can accept the invitation by clicking <a href=\""
                                                         + InviteUrl + "\">here</a><br><br>Best Regards,<br> ProjectMayhem Team");

                        return(RedirectToAction("Members", "Team"));
                    }
                    AddErrors(result);
                }
                else
                {
                    ModelState.AddModelError("", "The User already exist");
                }
            }
            var currentUser = User.Identity.GetUserId();

            model.TeamMembers = UserManager.Users.Where(x => x.teamLead.Id == currentUser).ToList();
            // If we got this far, something failed, redisplay form
            return(View(model));
        }
        public async Task<ActionResult> AddPayment(Guid id, PaymentDetailsViewModel model)
        {
            if (!ModelState.IsValid)
            {
                var data = await mediator.SendAsync(new GetImportNotificationAccountOverview(id));
                var accountManagementViewModel = new AccountManagementViewModel(data);
                accountManagementViewModel.RefundViewModel = await GetNewRefundDetailsViewModel(id);
                accountManagementViewModel.PaymentViewModel = model;
                accountManagementViewModel.ShowPaymentDetails = true;

                return View("Index", accountManagementViewModel);
            }

            await mediator.SendAsync(new AddNotificationPayment(id,
                model.PaymentAmount.Value,
                model.PaymentMethod,
                model.PaymentDate.AsDateTime().Value,
                model.ReceiptNumber,
                model.PaymentComments));

            return RedirectToAction("Index", "AccountManagement");
        }
        public async Task <ActionResult> DeleteAccount(AccountManagementViewModel model)
        {
            var SelectedId = model.EmpId;

            Debug.WriteLine(SelectedId + " This ID");
            var currentUser  = User.Identity.GetUserId();
            var deletionUser = UserManager.FindById(SelectedId);

            if (UserManager.Users.Where(x => x.teamLead.Id == deletionUser.Id).ToArray().Length == 0 && deletionUser.teamLead.Id == currentUser && deletionUser != null)
            {
                await UserManager.DeleteAsync(deletionUser);

                TempData["DelConfirmation"] = "The user was deleted";
            }
            else if (deletionUser == null)
            {
                TempData["DeleteError"] = "The Team member does not exist";
            }
            else
            {
                TempData["DeleteError"] = "Cannot delete a member. User is a Team Leader or you do not have permission";
            }
            return(this.RedirectToAction("Register"));
        }
        public async Task <ActionResult> AddPayment(Guid id, PaymentDetailsViewModel model)
        {
            if (!ModelState.IsValid)
            {
                var data = await mediator.SendAsync(new GetImportNotificationAccountOverview(id));

                var accountManagementViewModel = new AccountManagementViewModel(data);
                accountManagementViewModel.RefundViewModel = await GetNewRefundDetailsViewModel(id);

                accountManagementViewModel.PaymentViewModel   = model;
                accountManagementViewModel.ShowPaymentDetails = true;

                return(View("Index", accountManagementViewModel));
            }

            await mediator.SendAsync(new AddNotificationPayment(id,
                                                                model.PaymentAmount.Value,
                                                                model.PaymentMethod,
                                                                model.PaymentDate.AsDateTime().Value,
                                                                model.ReceiptNumber,
                                                                model.PaymentComments.Trim()));

            return(RedirectToAction("Index", "AccountManagement"));
        }
Beispiel #26
0
 public AccountManagementPage()
 {
     InitializeComponent();
     BindingContext = new AccountManagementViewModel(this);
 }
        public async Task<ActionResult> AddRefund(RefundDetailsViewModel model)
        {
            if (!ModelState.IsValid)
            {
                var data = await mediator.SendAsync(new GetAccountManagementData(model.NotificationId));
                var accountManagementViewModel = new AccountManagementViewModel(data);
                accountManagementViewModel.PaymentViewModel = new PaymentDetailsViewModel { NotificationId = model.NotificationId };
                accountManagementViewModel.RefundViewModel = model;
                accountManagementViewModel.ShowRefundDetails = true;

                return View("Index", accountManagementViewModel);
            }

            var refundData = new NotificationTransactionData
            {
                Date = model.RefundDate.AsDateTime().Value,
                NotificationId = model.NotificationId,
                Debit = Convert.ToDecimal(model.RefundAmount),
                Comments = model.Comments,
                ReceiptNumber = "NA"
            };

            await mediator.SendAsync(new AddNotificationTransaction(refundData));

            return RedirectToAction("index", "AccountManagement", new { id = model.NotificationId });
        }
 public AccountManagementView(ApplicationContext context)
 {
     InitializeComponent();
     _viewModel       = new AccountManagementViewModel(context);
     this.DataContext = _viewModel;
 }