예제 #1
0
        public IEnumerable <ApplicationUserDto> GetAll()
        {
            service = DIContainerST.GetInstance().Resolve <IUserService>();
            var user = service.GetAllUsers();

            return(user);
        }
예제 #2
0
        public ItemsPaginingParametersDto UsersPage(ItemsPaginingParametersDto pageDto)
        {
            service = DIContainerST.GetInstance().Resolve <IUserService>();
            var user = service.GetUsersOnPage(pageDto);

            return(user);
        }
예제 #3
0
        public ApplicationUserDto GetUserByID(string id)
        {
            service = DIContainerST.GetInstance().Resolve <IUserService>();
            var user = service.GetUserById(id);

            return(user);
        }
예제 #4
0
        public async Task <IHttpActionResult> Register(RegisterBindingModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var user = new ApplicationUser()
            {
                UserName = model.Email, Email = model.Email
            };
            IdentityResult result = await UserManager.CreateAsync(user, model.Password);

            userService = DIContainerST.GetInstance().Resolve <IUserService>();
            var    guid = userService.InitDetails(user.Id);
            string link = Url.Link("ActionApi", new { Controller = "Account", Action = "ValidateEmail", username = model.Email, token = guid });

            emailService = DIContainerST.GetInstance().Resolve <IEmailService>();
            if (result.Succeeded)
            {
                emailService.SendEmail("*****@*****.**", Const.EmailConfirmationSubject, string.Format(Const.EmailConfirmationBody, link));
            }
            else
            {
                return(GetErrorResult(result));
            }
            return(Ok());
        }
        public List <string> GetReviewsById(string id)
        {
            service = DIContainerST.GetInstance().Resolve <IReviewService>();
            var user = service.GetReviewsByUserId(id);

            return(user);
        }
        public IEnumerable <UserReviewDto> GetAll()
        {
            service = DIContainerST.GetInstance().Resolve <IReviewService>();
            var user = service.GetAllReviews();

            return(user);
        }
 public IHttpActionResult AddOrUpdate(UserReviewDto user)
 {
     user.ApplicationUserId = RequestContext.Principal.Identity.GetUserId();
     service = DIContainerST.GetInstance().Resolve <IReviewService>();
     service.AddOrUpdateReview(user);
     return(Ok());
 }
예제 #8
0
        public ProductDetailsDto GetProductByID(int id)
        {
            service = DIContainerST.GetInstance().Resolve <IProductService>();
            var product = service.GetProductById(id);

            return(product);
        }
예제 #9
0
        public IEnumerable <ProductDetailsDto> GetAll()
        {
            service = DIContainerST.GetInstance().Resolve <IProductService>();
            var products = service.GetAllProducts();

            return(products);
        }
예제 #10
0
        public ApplicationUserDto GetUserByUserName()
        {
            var id = RequestContext.Principal.Identity.GetUserId();

            service = DIContainerST.GetInstance().Resolve <IUserService>();
            var user = service.GetUserById(id);

            return(user);
        }
예제 #11
0
        public async Task <IHttpActionResult> EditUser(ApplicationUserDto user)
        {
            var id = RequestContext.Principal.Identity.GetUserId();

            await AdminAuthorization(id);

            service = DIContainerST.GetInstance().Resolve <IUserService>();
            service.AddOrUpdateUser(user);

            return(Ok());
        }
예제 #12
0
        public async Task <IHttpActionResult> ResetPassword(ResetPasswordBindingModel model)
        {
            emailService = DIContainerST.GetInstance().Resolve <IEmailService>();
            var user = await UserManager.FindByEmailAsync(model.Email);

            var code = await UserManager.GeneratePasswordResetTokenAsync(user.Id);

            IdentityResult result = await UserManager.ResetPasswordAsync(user.Id, code, model.NewPassword);

            if (result.Succeeded)
            {
                emailService.SendEmail(/*model.Email*/ "*****@*****.**", Const.EmailChangePasswordSubject, Const.EmailResetPasswordBody);
            }
            else
            {
                return(GetErrorResult(result));
            }
            return(Ok());
        }
예제 #13
0
        public async Task <IHttpActionResult> ForgotPassword(ForgotPasswordBindingModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var user = await UserManager.FindByEmailAsync(model.Email);

            emailService = DIContainerST.GetInstance().Resolve <IEmailService>();
            string email1 = "*****@*****.**";

            if (user != null)
            {
                string link = string.Format("http://localhost:6251/index.html#!/resetpassword?username={0}", model.Email);
                emailService.SendEmail(/*model.Email*/ email1, Const.EmailForgotPasswordSubject, string.Format(Const.EmailForgotPasswordBody, link));
            }

            return(Ok());
        }
예제 #14
0
        public async Task <IHttpActionResult> Register(RegisterBindingModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var user = new ApplicationUser()
            {
                UserName = model.Email, Email = model.Email
            };
            IdentityResult result = await UserManager.CreateAsync(user, model.Password);

            service = DIContainerST.GetInstance().Resolve <IUserService>();
            service.InitDetails(user.Id);
            if (!result.Succeeded)
            {
                return(GetErrorResult(result));
            }

            return(Ok());
        }
예제 #15
0
        public async Task <IHttpActionResult> ChangePassword(ChangePasswordBindingModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            IdentityResult result = await UserManager.ChangePasswordAsync(User.Identity.GetUserId(), model.OldPassword, model.NewPassword);

            emailService = DIContainerST.GetInstance().Resolve <IEmailService>();
            var    id    = RequestContext.Principal.Identity.GetUserId();
            string email = UserManager.GetEmail(id);

            if (result.Succeeded)
            {
                emailService.SendEmail(email, Const.EmailChangePasswordSubject, Const.EmailChangePasswordBody);
            }
            else
            {
                return(GetErrorResult(result));
            }

            return(Ok());
        }
예제 #16
0
        public async Task <IHttpActionResult> AddUser(ApplicationUserDto userDto)
        {
            var id = RequestContext.Principal.Identity.GetUserId();

            await AdminAuthorization(id);

            var user = new ApplicationUser()
            {
                UserName = userDto.Email, Email = userDto.Email
            };
            IdentityResult result = await UserManager.CreateAsync(user, userDto.Password);

            service = DIContainerST.GetInstance().Resolve <IUserService>();
            service.InitDetails(user.Id);
            if (!result.Succeeded)
            {
                return(GetErrorResult(result));
            }
            service = DIContainerST.GetInstance().Resolve <IUserService>();
            service.AddOrUpdateUser(userDto);

            return(Ok());
        }
예제 #17
0
        public HttpResponseMessage ValidateEmail(string username, string token)
        {
            userRepository = DIContainerST.GetInstance().Resolve <IRepository <ApplicationUser> >();
            userService    = DIContainerST.GetInstance().Resolve <IUserService>();
            userService.ValidateEmail(username, token);
            var response = new HttpResponseMessage();

            response.Content = new StringContent("<html>" +
                                                 "<body>" +
                                                 "<h1>" +
                                                 "Confirm Email " +
                                                 "<p>" +
                                                 Const.EmailConfirmation +
                                                 "<a href='http://localhost:6251/index.html#!/login'> " +
                                                 " click here to Log In" +
                                                 "</a>" +
                                                 "</p>" +
                                                 "</h1>" +
                                                 "</body>" +
                                                 "</html>");
            response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html");
            return(response);
        }
예제 #18
0
 public IHttpActionResult AddOrUpdate(ApplicationUserDto user)
 {
     service = DIContainerST.GetInstance().Resolve <IUserService>();
     service.AddOrUpdateUser(user);
     return(Ok());
 }
예제 #19
0
 public IHttpActionResult AddOrUpdateProduct(ProductDetailsDto product)
 {
     service = DIContainerST.GetInstance().Resolve <IProductService>();
     service.AddOrUpdateProduct(product);
     return(Ok());
 }
예제 #20
0
 public IHttpActionResult Delete(string id)
 {
     service = DIContainerST.GetInstance().Resolve <IUserService>();
     service.DeleteUser(id);
     return(Ok());
 }