Exemplo n.º 1
0
 public DoctorController(
     DoctorAppService doctorAppService,
     AccountAppService accountAppService,
     GeneralAppService generalAppService,
     IHttpContextAccessor httpContextAccessor,
     Doctor_DoctorServiceAppService doctor_DoctorServiceAppService,
     DoctorSubSpecializationAppService doctorSubSpecialization,
     ClinicAppService clinicAppService,
     ClinicImagesAppService clinicImagesAppService,
     AreaAppService areaAppService,
     CityAppService cityAppService,
     WorkingDayAppService workingDayAppService,
     DayShiftAppService dayShiftAppService,
     RatingAppService ratingAppService,
     ReservationAppService reservationAppService)
 {
     _doctorAppService               = doctorAppService;
     _accountAppService              = accountAppService;
     _generalAppService              = generalAppService;
     _httpContextAccessor            = httpContextAccessor;
     _doctor_DoctorServiceAppService = doctor_DoctorServiceAppService;
     _doctorSubSpecialization        = doctorSubSpecialization;
     _clinicAppService               = clinicAppService;
     _clinicImagesAppService         = clinicImagesAppService;
     _areaAppService        = areaAppService;
     _cityAppService        = cityAppService;
     _workingDayAppService  = workingDayAppService;
     _dayShiftAppService    = dayShiftAppService;
     _ratingAppService      = ratingAppService;
     _reservationAppService = reservationAppService;
 }
Exemplo n.º 2
0
        public virtual async Task <IActionResult> OnPostAsync()
        {
            try
            {
                await AccountAppService.SendPasswordResetCodeAsync(
                    new SendPasswordResetCodeDto
                {
                    Email         = Email,
                    AppName       = "MVC",
                    ReturnUrl     = ReturnUrl,
                    ReturnUrlHash = ReturnUrlHash
                }
                    );

                return(RedirectToPage(
                           "./PasswordResetLinkSent",
                           new
                {
                    returnUrl = ReturnUrl,
                    returnUrlHash = ReturnUrlHash
                }));
            }
            catch (BusinessException e)
            {
                var message = GetLocalizeExceptionMessage(e);
                MyAlerts.Warning(message, L["OperationFailed"]);
                return(await OnGetAsync());
            }
        }
        public virtual async Task <IActionResult> OnPostAsync()
        {
            try
            {
                ValidateModel();

                await AccountAppService.ResetPasswordAsync(
                    new ResetPasswordDto
                {
                    UserId     = UserId,
                    ResetToken = ResetToken,
                    Password   = Password
                }
                    );
            }
            catch (Exception e)
            {
                var message = GetMessageFromException(e);
                MyAlerts.Warning(message, L["OperationFailed"]);
                return(await OnGetAsync());
            }

            //TODO: Try to automatically login!
            return(RedirectToPage("./ResetPasswordConfirmation", new
            {
                returnUrl = ReturnUrl,
                returnUrlHash = ReturnUrlHash
            }));
        }
Exemplo n.º 4
0
        public virtual async Task <IActionResult> OnPostAsync()
        {
            ValidateModel();

            try
            {
                await AccountAppService.ResetPasswordAsync(
                    new ResetPasswordDto
                {
                    UserId     = UserId,
                    ResetToken = ResetToken,
                    Password   = Password
                }
                    );
            }
            catch (AbpIdentityResultException e)
            {
                if (!string.IsNullOrWhiteSpace(e.Message))
                {
                    Alerts.Warning(GetLocalizeExceptionMessage(e));
                    return(Page());
                }

                throw;
            }

            //TODO: Try to automatically login!
            return(RedirectToPage("./ResetPasswordConfirmation", new
            {
                returnUrl = ReturnUrl,
                returnUrlHash = ReturnUrlHash
            }));
        }
Exemplo n.º 5
0
        public async Task VerifyGetDebitTransaction_ReturnAccountViewModelTestAsync()
        {
            var account = AccountMock.AccountModelFaker.Generate();
            var transactionDebitInputViewModel = TransactionMock.TransactionDebitInputViewModelModelFaker.Generate();

            _mapperMock.Setup(x => x.Map <Transaction>(It.IsAny <TransactionInputViewModel>()))
            .Returns(TransactionMock.TransactionModelFakerTyped(transactionDebitInputViewModel).Generate());

            _mapperMock.Setup(x => x.Map <TransactionViewModel>(It.IsAny <Transaction>()))
            .Returns(TransactionMock.TransactionViewModelModelFaker.Generate());

            _accountRepositoryMock.Setup(x => x.GetAccountById(account.Id))
            .ReturnsAsync(AccountMock.AccountModelFaker.Generate());

            _transactionServiceMock.Setup(x => x.DebitAccount(It.IsAny <Transaction>()))
            .Returns(Task.CompletedTask);

            var accountAppService = new AccountAppService(_accountRepositoryMock.Object,
                                                          _mapperMock.Object, _transactionServiceMock.Object, _domainNotificationMock.Object);

            var accountMethod = await accountAppService.Transaction(transactionDebitInputViewModel);

            var accountResult = Assert.IsAssignableFrom <TransactionViewModel>(accountMethod);

            _transactionServiceMock.Verify(x => x.DebitAccount(It.IsAny <Transaction>()), Times.Once());
            Assert.NotNull(accountResult);
        }
Exemplo n.º 6
0
        public virtual async Task <IActionResult> OnPostAsync()
        {
            try
            {
                await AccountAppService.SendPasswordResetCodeAsync(
                    new SendPasswordResetCodeDto
                {
                    Email         = Email,
                    AppName       = "MVC", //TODO: Const!
                    ReturnUrl     = ReturnUrl,
                    ReturnUrlHash = ReturnUrlHash
                }
                    );
            }
            catch (UserFriendlyException e)
            {
                Alerts.Danger(GetLocalizeExceptionMessage(e));
                return(Page());
            }


            return(RedirectToPage(
                       "./PasswordResetLinkSent",
                       new
            {
                returnUrl = ReturnUrl,
                returnUrlHash = ReturnUrlHash
            }));
        }
Exemplo n.º 7
0
        protected virtual async Task RegisterExternalUserAsync(ExternalLoginInfo externalLoginInfo, string emailAddress)
        {
            var userDto = await AccountAppService.RegisterAsync(
                new RegisterDto
            {
                AppName      = "MVC",
                EmailAddress = Input.EmailAddress,
                Password     = Input.Password,
                UserName     = Input.UserName
            }
                );

            var user = await UserManager.GetByIdAsync(userDto.Id);

            var userLoginAlreadyExists = user.Logins.Any(x =>
                                                         x.TenantId == user.TenantId &&
                                                         x.LoginProvider == externalLoginInfo.LoginProvider &&
                                                         x.ProviderKey == externalLoginInfo.ProviderKey);

            if (!userLoginAlreadyExists)
            {
                (await UserManager.AddLoginAsync(user, new UserLoginInfo(
                                                     externalLoginInfo.LoginProvider,
                                                     externalLoginInfo.ProviderKey,
                                                     externalLoginInfo.ProviderDisplayName
                                                     ))).CheckErrors();
            }

            await SignInManager.SignInAsync(user, true);
        }
Exemplo n.º 8
0
 public AccountController(AccountAppService accountAppService, GeneralAppService generalAppService, IHttpContextAccessor httpContextAccessor,
                          UserManager <ApplicationUserIdentity> userManager, IMailService mailService)
 {
     _accountAppService   = accountAppService;
     _generalAppService   = generalAppService;
     _httpContextAccessor = httpContextAccessor;
     this._userManager    = userManager;
     _mailService         = mailService;
 }
 public MonitorController(IMultiTenancyConfig multiTenancyConfig, IWebSessionCache webSessionCache, AccountAppService accountAppService, SignInManager signInManager, LogInManager logInManager,
                          AbpLoginResultTypeHelper abpLoginResultTypeHelper)
 {
     _multiTenancyConfig       = multiTenancyConfig;
     _webSessionCache          = webSessionCache;
     _accountAppService        = accountAppService;
     _signInManager            = signInManager;
     _logInManager             = logInManager;
     _abpLoginResultTypeHelper = abpLoginResultTypeHelper;
 }
Exemplo n.º 10
0
 public AccountController(AbpLoginResultTypeHelper abpLoginResultTypeHelper, LogInManager logInManager, SignInManager signInManager, ITenantCache tenantCache, INotificationPublisher notificationPublisher, AccountAppService accountAppService, UserManager userManager)
 {
     _abpLoginResultTypeHelper = abpLoginResultTypeHelper;
     _logInManager             = logInManager;
     _signInManager            = signInManager;
     _tenantCache           = tenantCache;
     _notificationPublisher = notificationPublisher;
     _accountAppService     = accountAppService;
     _userManager           = userManager;
 }
        public AccountController(
            AccountAppService accountAppService,
            IAbpSession abpSession,
            JwtTokenHandler jwtTokenHandler)
        {
            _AccountAppService = accountAppService;

            _AbpSession = abpSession;

            _JwtTokenHandler = jwtTokenHandler;
        }
Exemplo n.º 12
0
        public ActionResult Login(string username, string password, bool IsRemember)
        {
            if (username.IsNullOrEmpty() || password.IsNullOrEmpty())
            {
                return(this.FailedMsg("用户名/密码不能为空"));
            }

            username = username.Trim();

            const string moduleName = "系统登录";
            string       ip         = WebHelper.GetUserIP();

            Sys_User user;
            string   msg;


            IAccountAppService _IAccountAppService = new AccountAppService();

            //IGetFeeData _IGetFeeData = new GetFeeData();

            if (!_IAccountAppService.CheckLogin(username, password, out user, out msg))
            {
                Logger.Write("Login", moduleName, "用户名" + username + msg);

                return(this.FailedMsg(msg));
            }

            AdminSession session = new AdminSession();

            session.UserId      = user.Id;
            session.UserName    = user.UserName;
            session.RealName    = user.RealName;
            session.LoginIP     = ip;
            session.LoginTime   = DateTime.Now;
            session.headIcon    = user.HeadIcon;
            session.Description = user.Description;
            session.WeChat      = user.WeChat;
            session.IsAdmin     = user.UserName.ToLower() == AppConsts.AdminUserName;
            session.IsRemember  = IsRemember;
            //session.Habit = _IGetFeeData.LookUserHabit(this.CurrentSession.UserName);
            this.CurrentSession = session;


            IGetFeeData GetData = new GetFeeData();

            //int result = GetData.InserIntoBankSystem("");

            Logger.Write("Login", moduleName, "用户名" + username + msg);

            return(this.SuccessMsg(msg));
        }
Exemplo n.º 13
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(
            IApplicationBuilder app,
            IWebHostEnvironment env,
            RoleAppService _roleAppService,
            AccountAppService _accountAppService)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseSwagger();
                app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "API v1"));
            }

            app.UseRouting();

            app.UseAuthentication();

            app.UseAuthorization();

            app.UseCors(
                options => options
                .AllowAnyMethod()
                .AllowAnyHeader()
                .SetIsOriginAllowed(origin => true) // allow any origin
                .AllowCredentials());

            // make uploaded images stored in the Resources folder
            //  make Resources folder it servable as well
            app.UseStaticFiles();
            app.UseStaticFiles(new StaticFileOptions()
            {
                FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), @"Resources")),
                RequestPath  = new PathString("/Resources")
            });
            app.UseStaticFiles(new StaticFileOptions()
            {
                FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), @"StaticFiles")),
                RequestPath  = new PathString("/StaticFiles")
            });
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            // create custom roles
            _roleAppService.CreateRoles().Wait();
            // add custom first admin
            //accountAppService.CreateFirstAdmin().Wait();
        }
Exemplo n.º 14
0
        public ActionResult EditPassword(string oldPassword, string newPassword)
        {
            IAccountAppService _IAccountAppService = new AccountAppService();

            string msg = string.Empty;

            bool IsSuccess = _IAccountAppService.ChangePassword(this.CurrentSession.UserName, oldPassword, newPassword, out msg);

            if (IsSuccess)
            {
                return(this.SuccessMsg(msg));
            }
            else
            {
                return(this.FailedMsg(msg));
            }
        }
        protected virtual async Task RegisterLocalUserAsync()
        {
            ValidateModel();

            var userDto = await AccountAppService.RegisterAsync(
                new RegisterDto
                {
                    AppName = "MVC",
                    EmailAddress = Input.EmailAddress,
                    Password = Input.Password,
                    UserName = Input.UserName
                }
            );

            var user = await UserManager.GetByIdAsync(userDto.Id);
            await SignInManager.SignInAsync(user, isPersistent: true);
        }
Exemplo n.º 16
0
        public virtual async Task <IActionResult> OnPostAsync()
        {
            await CheckSelfRegistrationAsync();

            var registerDto = new RegisterDto()
            {
                AppName = "MVC"
            };

            if (IsExternalLogin)
            {
                var externalLoginInfo = await SignInManager.GetExternalLoginInfoAsync();

                if (externalLoginInfo == null)
                {
                    Logger.LogWarning("External login info is not available");
                    return(RedirectToPage("./Login"));
                }

                registerDto.EmailAddress = Input.EmailAddress;
                registerDto.UserName     = Input.EmailAddress;
                registerDto.Password     = GeneratePassword();
            }
            else
            {
                ValidateModel();

                registerDto.EmailAddress = Input.EmailAddress;
                registerDto.Password     = Input.Password;
                registerDto.UserName     = Input.UserName;
            }

            var userDto = await AccountAppService.RegisterAsync(registerDto);

            var user = await UserManager.GetByIdAsync(userDto.Id);

            await SignInManager.SignInAsync(user, isPersistent : false);

            if (IsExternalLogin)
            {
                await AddToUserLogins(user);
            }

            return(Redirect(ReturnUrl ?? "~/")); //TODO: How to ensure safety? IdentityServer requires it however it should be checked somehow!
        }
Exemplo n.º 17
0
        public void EventAppServiceStartup()
        {
            accountAppService = new AccountAppService();
            eventAppService   = new EventAppService();
            host = accountAppService.Find("TestHost", "TestHost");



            EventViewModel eventViewModel = new EventViewModel();

            eventViewModel.HostId   = host.Id;
            eventViewModel.Name     = "TestEvent1";
            eventViewModel.location = "Test";
            eventViewModel.price    = 4;
            eventViewModel.TotalAvailableTickets = 5;
            eventViewModel.category = 0;
            eventViewModel.date     = DateTime.Now;
            Event1 = eventAppService.SaveNewEvent(eventViewModel);
        }
Exemplo n.º 18
0
        public async Task GetAll_ReturnAccountViewModelTestAsync()
        {
            _accountRepositoryMock.Setup(x => x.GetAccounts())
            .ReturnsAsync(AccountMock.AccountModelFaker.Generate(3));

            _mapperMock.Setup(x =>
                              x.Map <IEnumerable <AccountViewModel> >(It.IsAny <IEnumerable <Account.Domain.Models.Account> >()))
            .Returns(AccountMock.AccountViewModelModelFaker.Generate(3));

            var accountAppService = new AccountAppService(_accountRepositoryMock.Object,
                                                          _mapperMock.Object, _transactionServiceMock.Object, _domainNotificationMock.Object);

            var accountMethod = await accountAppService.GetAll();

            var accountResult = Assert.IsAssignableFrom <IEnumerable <AccountViewModel> >(accountMethod);

            Assert.NotNull(accountResult);
            Assert.NotEmpty(accountResult);
        }
Exemplo n.º 19
0
        protected override async Task RegisterLocalUserAsync()
        {
            ValidateModel();

            var userDto = await AccountAppService.RegisterAsync(
                new RegisterDto
            {
                AppName      = "Abp.EmailMarketing",
                EmailAddress = Input.EmailAddress,
                Password     = Input.Password,
                UserName     = Input.UserName
            }
                );

            _abpIdentityUser = await UserManager.GetByIdAsync(userDto.Id);

            // Send user an email to confirm email address
            await SendEmailToAskForEmailConfirmationAsync(_abpIdentityUser);
        }
Exemplo n.º 20
0
        public AccountController(
            IEventService events,
            IIdentityServerInteractionService interaction,
            ValidateCodeHelper validateCodeHelper,
            AccountAppService accountAppService,
            IAbpSession abpSession,
            JwtTokenHandler jwtTokenHandler)
        {
            _Events = events;

            _Interaction = interaction;

            _ValidateCodeHelper = validateCodeHelper;

            _AccountAppService = accountAppService;

            _AbpSession = abpSession;

            _JwtTokenHandler = jwtTokenHandler;
        }
Exemplo n.º 21
0
        public virtual async Task <IActionResult> OnPostAsync()
        {
            await AccountAppService.SendPasswordResetCodeAsync(
                new SendPasswordResetCodeDto
            {
                Email         = Email,
                AppName       = "MVC", //TODO: Const!
                ReturnUrl     = ReturnUrl,
                ReturnUrlHash = ReturnUrlHash
            }
                );

            return(RedirectToPage(
                       "./PasswordResetLinkSent",
                       new
            {
                returnUrl = ReturnUrl,
                returnUrlHash = ReturnUrlHash
            }));
        }
Exemplo n.º 22
0
        public async Task GetByAccountId_ReturnTransactionViewModelTestAsync()
        {
            var transactions = TransactionMock.TransactionModelFaker.Generate(3);

            _accountRepositoryMock.Setup(x => x.GetTransactionsByAccountId(transactions.FirstOrDefault().AccountId))
            .ReturnsAsync(transactions);

            _mapperMock.Setup(x =>
                              x.Map <IEnumerable <TransactionViewModel> >(It.IsAny <IEnumerable <Transaction> >()))
            .Returns(TransactionMock.TransactionViewModelModelFaker.Generate(3));

            var accountAppService = new AccountAppService(_accountRepositoryMock.Object,
                                                          _mapperMock.Object, _transactionServiceMock.Object, _domainNotificationMock.Object);

            var accountMethod = await accountAppService.GetByAccountId(transactions.FirstOrDefault().AccountId);

            var accountResult = Assert.IsAssignableFrom <IEnumerable <TransactionViewModel> >(accountMethod);

            Assert.NotNull(accountResult);
            Assert.NotEmpty(accountResult);
        }
Exemplo n.º 23
0
        [UnitOfWork] //TODO: Will be removed when we implement action filter
        public virtual async Task <IActionResult> OnPostAsync()
        {
            ValidateModel();

            await CheckSelfRegistrationAsync();

            var registerDto = new RegisterDto {
                AppName      = "MVC",
                EmailAddress = Input.EmailAddress,
                Password     = Input.Password,
                UserName     = Input.UserName
            };

            var userDto = await AccountAppService.RegisterAsync(registerDto);

            var user = await UserManager.GetByIdAsync(userDto.Id);

            await UserManager.SetEmailAsync(user, Input.EmailAddress);

            await SignInManager.SignInAsync(user, isPersistent : false);

            return(Redirect(ReturnUrl ?? "/")); //TODO: How to ensure safety? IdentityServer requires it however it should be checked somehow!
        }
Exemplo n.º 24
0
        public ActionResult CreateEvent(EventViewModel newEvent, HttpPostedFileBase file)
        {
            ViewBag.ImageError = null;
            if (!ModelState.IsValid || file == null)
            {
                if (file == null)
                {
                    ViewBag.ImageError = "Please add an image for the event.";
                }
                return(View(newEvent));
            }

            var image = System.IO.Path.GetFileName(file.FileName);

            file.SaveAs(Server.MapPath("~/Content/" + image));
            newEvent.image = image;

            AccountAppService accountAppService = new AccountAppService();

            newEvent.HostId = User.Identity.GetUserId();

            eventAppService.SaveNewEvent(newEvent);
            return(RedirectToAction("Index"));
        }
Exemplo n.º 25
0
 public AccountController(AccountAppService appService)
 {
     this.appService = appService;
 }
Exemplo n.º 26
0
 public void Intial()
 {
     account = new AccountAppService();
 }
Exemplo n.º 27
0
 public void HostUserSetUp()
 {
     hostUserAppService = new HostUserAppService();
     accountAppService  = new AccountAppService();
     hostUser           = accountAppService.Find("TestHost", "TestHost");
 }
Exemplo n.º 28
0
 public UserController(AccountAppService userService)
 {
     this.userService = userService;
 }
Exemplo n.º 29
0
 public void ShoppingCartSetup()
 {
     accountAppService      = new AccountAppService();
     shoppingCartAppService = new ShoppingCartAppService();
     user = accountAppService.Find("TestUser", "TestUser");
 }
Exemplo n.º 30
0
 public TestController(AccountAppService service)
 {
     this.service = service;
 }