Beispiel #1
0
        public ActionResult Details(int id, [DefaultValue(1)] int page)
        {
            bool isConfirmed = false;

            ServiceViewModel service = _serviceRepo.GetServiceViewModelById(id);
            IQueryable <CommentViewModel> comments = _commentRepo.GetCommentViewModelByServiceId(service.ServiceId);

            //sprawdzam czy uslugodawca ma potwierdzone konto jesli tak to bedzie mogl przegladac komentarze
            ServiceProvider serviceProvider = _serviceProviderRepo.GetServiceProviderByUserId(User.Identity.GetUserId());

            if (serviceProvider != null && serviceProvider.IsConfirmed)
            {
                isConfirmed = true;
            }
            //sprawdzam czy uslugobiorca ma potwierdzone konto jesli tak to bedzie mogl przegladac komentarze
            Customer customer = _customerRepo.GetCustomerByUserId(User.Identity.GetUserId());

            if (customer != null && customer.IsConfirmed)
            {
                isConfirmed = true;
            }

            IPagination <CommentViewModel> commentList = comments.OrderBy("Date", SortDirection.Ascending).AsPagination(page, 5);

            ServiceCommentsViewModel serviceCommentsViewModel = new ServiceCommentsViewModel
            {
                Service          = service,
                CommentPagedList = commentList,
                ConfirmedUser    = isConfirmed
            };

            return(View(serviceCommentsViewModel));
        }
        public ActionResult Change()
        {
            // Pobranie aktualnie zalogowanego użytkownika i przekierowanie do akcji Edit
            var provider = _providerRepo.GetServiceProviderByUserId(WebSecurity.CurrentUserId);

            return(RedirectToAction("Edit", new { id = provider.Id }));
        }
        public ActionResult Confirm(string name, string securityCode)
        {
            int id = WebSecurity.GetUserId(name);

            // Pobranie usługobiorcy po identyfikatorze użytkownika (nie wiadomo, czy potwierdzany użytkownik jest usługodawcą, czy usługobiorcą)
            var customer = _customerRepo.GetCustomerByUserId(id);

            // Pobranie usługodawcy po identyfikatorze użytkownika (nie wiadomo, czy potwierdzany użytkownik jest usługodawcą, czy usługobiorcą)
            var provider = _serviceProviderRepo.GetServiceProviderByUserId(id);

            // Jeśli użytkownik nie jest usługodawcą lub usługobiorcą, to jest to błąd.
            if (customer == null && provider == null)
            {
                TempData["Error"] = "Błąd weryfikacji konta!";
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                string hashDateInDatebase = string.Empty;

                if (customer != null)
                {
                    hashDateInDatebase = Konto.CalculateConfirmationCode(name, customer.Email, customer.RegistrationDate);
                }
                else
                {
                    hashDateInDatebase = Konto.CalculateConfirmationCode(name, provider.Email, provider.RegistrationDate);
                }

                // Jeżeli wyliczony kod zabezpieczający jest taki sam jak kod przesłany, to konto jest potwierdzone.
                if (securityCode.Equals(hashDateInDatebase, StringComparison.InvariantCultureIgnoreCase))
                {
                    if (provider != null)
                    {
                        // Potwierdzenie konta usługodawcy
                        provider.IsConfirmed = true;
                        _serviceProviderRepo.SaveChanges();
                    }
                    else
                    {
                        // Potwierdzenie konta usługobiorcy
                        customer.IsConfirmed = true;
                        _customerRepo.SaveChanges();
                    }

                    TempData["Message"] = "Pomyślnie potwierdzono adres e-mail!";
                }
                else
                {
                    //  Jeżeli wyliczony kod zabezpieczający jest różny od kodu przesłanego to zwracany jest błąd.
                    TempData["Error"] = "Błąd weryfikacji konta!";
                }
            }

            return(RedirectToAction("Index", "Home"));
        }
        public ActionResult Create()
        {
            ServiceProvider serviceProvider = _serviceProviderRepo.GetServiceProviderByUserId(User.Identity.GetUserId());

            //jesli uzytkownik ma juz uzupelniony profil to przekierowujemy do edycji
            if (serviceProvider != null)
            {
                return(RedirectToAction("Edit", new { id = serviceProvider.ServiceProviderId }));
            }

            return(View());
        }