Exemple #1
0
 public bool createUser(RegisterViewModel registerModel)
 {
     if ((registerModel.userPassword != registerModel.userRePassword) || !checkEmailAdressCreate(registerModel.userEmailAdress) ||
         !checkUserNameSurname(registerModel.userName, registerModel.userSurname) ||
         !checkUserPassword(registerModel.userPassword) || !checkPhoneNumber(registerModel.userPhoneNumber))
     {
         ToastrService.AddToUserQueue(new Toastr("Kayıt sırasında bir hata oluştu.", type: Model.Enums.ToastrType.Error));
         return(false);
     }
     else
     {
         Users model = new Users();
         model = _mapper.Map <Users>(registerModel);
         model.userPhoneNumber = Regex.Replace(model.userPhoneNumber, @"[^0-9]+", "");
         model.role            = Model.Enums.UserRoleEnum.customer;
         model.status          = Model.Enums.UserStatusEnum.Waiting;
         model.userCreateDate  = DateTime.Now;
         _mainContext.Add(model);
         if (_mainContext.SaveChanges() == 1)
         {
             return(true);
         }
         else
         {
             ToastrService.AddToUserQueue(new Toastr("Kayıt sırasında bir hata oluştu.", type: Model.Enums.ToastrType.Error));
             return(false);
         }
     }
 }
Exemple #2
0
        public bool changeRegisterUserPassword(RegisterViewModel model)
        {
            string userId = getUserIdFromUserToken(new Guid(model.accessToken));

            if (userId != null && (model.userPassword == model.userRePassword) && checkUserPassword(model.userPassword))
            {
                Users userStatus = _mainContext.users.Where(w => w.userId == new Guid(userId)).FirstOrDefault();
                userStatus.userPassword = model.userPassword;
                if (_mainContext.SaveChanges() == 1)
                {
                    ToastrService.AddToUserQueue(new Toastr("Şifreniz başarıyla sıfırlanmıştır.", type: Model.Enums.ToastrType.Success));
                    changeTokenStatus(new Guid(model.accessToken));
                    return(true);
                }

                else
                {
                    ToastrService.AddToUserQueue(new Toastr("Şifreniz sıfırlanırken bir hata ile karşılaşıldı.Parolanıza bir öncekiyle aynı olmamalıdır.", type: Model.Enums.ToastrType.Error));
                    return(false);
                }
            }
            else
            {
                ToastrService.AddToUserQueue(new Toastr("Şifreniz sıfırlanırken bir hata ile karşılaşıldı. Lütfen parolanızı kontrol ediniz.", type: Model.Enums.ToastrType.Error));
                return(false);
            }
        }
Exemple #3
0
        public void checkRegisterToken(Guid tokenid)
        {
            var userToken = _mainContext.usersTokens.Where(w => w.tokenId == tokenid && w.status == UsersTokenEnum.Active).FirstOrDefault();

            if (userToken != null)
            {
                Guid getUserId = userToken.userId;
                if (getUserToken(UsersTokenTypeEnum.register, getUserId) == tokenid.ToString())
                {
                    if (changeTokenStatus(tokenid) && changeRegisterUserStatus(getUserId))
                    {
                        ToastrService.AddToUserQueue(new Toastr("Hesabınız başarıyla aktif edilmiştir.", type: Model.Enums.ToastrType.Success));
                    }
                    else
                    {
                        ToastrService.AddToUserQueue(new Toastr("Hesabınız aktif edilirken bir hata gerçekleşmiştir.", type: Model.Enums.ToastrType.Error));
                    }
                }
                else
                {
                    ToastrService.AddToUserQueue(new Toastr("Hesabınız aktif edilirken bir hata gerçekleşmiştir.", type: Model.Enums.ToastrType.Error));
                }
            }
            else
            {
                ToastrService.AddToUserQueue(new Toastr("Hesabınız aktif edilirken bir hata gerçekleşmiştir.", type: Model.Enums.ToastrType.Error));
            }
        }
 BrandApplicationViewModel submitBrandApplication(BrandApplicationViewModel gettingModel)
 {
     if (gettingModel.applicationType == ApplicationTypesEnum.domestic && gettingModel.applicationCategoryType == ApplicationCategoryTypesEnum.brand && gettingModel.selectedBrandApplication == 1)
     { // burada marka başvurusu yurtiçi olan
         if (checkSaveBasketPossibilty(gettingModel))
         {
             if (_basketService.addBasket(gettingModel))
             {
                 ToastrService.AddToUserQueue(new Toastr("Talebiniz sepete eklenmiştir.", type: Model.Enums.ToastrType.Success));
                 BrandApplicationViewModel returnModel = getBrandAppStandartValues(gettingModel);
                 returnModel.saveStatus = BasketSaveStatusEnum.success;
                 return(returnModel);
             }
             else
             {
                 ToastrService.AddToUserQueue(new Toastr("Sepete Eklenirken bir hata gerçekleşti.", type: Model.Enums.ToastrType.Error));
                 return(getInformationForBrandApplicationTypeChoose(gettingModel));
             }
         }
         else
         {
             return(getInformationForBrandApplicationTypeChoose(gettingModel));
         }
     }
     else
     {
         return(null);
     }
 }
        BrandApplicationViewModel getInformationForBrandApplicationTypeChoose(BrandApplicationViewModel gettingModel)  // burada marka için yapılacak işlemin tipi seçildiğinde yapılacaklar
        {
            BrandApplicationViewModel model = gettingModel;

            model        = getBrandAppStandartValues(gettingModel);
            model.prices = _applicationPricesService.getPrices(model.selectedBrandApplication);//standart gelmesi gerek her zaman için
            model.brandApplicationVisibilty = _mapper.Map <BrandApplicationVisibilityViewModel>(_mainContext.brandApplicationVisiblities.Where(w => w.brandApplicationTypesId == gettingModel.selectedBrandApplication).FirstOrDefault());
            if (model.brandApplicationVisibilty != null && model.brandApplicationVisibilty.applicationClassStatus)
            { // burada eğer  sınıfların gelmesini istiyorsak listeyi çeker
                model.applicationClassList    = _brandApplicationClassesService.getApplicationClassList();
                model.applicationSubClassList = _brandApplicationClassesService.getApplicationSubClassList(model.subclassSearchText);
                if (model.subclassSearchText != null)
                {
                    model.applicationClassList = _brandApplicationClassesService.applicationClassFillWithSelecteds(model.applicationClassList, model.applicationSubClassList);
                    // model.prices.totalPrice = _applicationPricesService.brandApplicationTotalPrice(model);
                    double calculatedPrice = _applicationPricesService.brandApplicationTotalPrice(model);
                    model.prices.totalPrice = calculatedPrice;
                    if (model.applicationSubClassList.subList.Where(w => w.isSelected).Count() == 0)
                    {
                        ToastrService.AddToUserQueue(new Toastr("Aradığınız bilgilerde bir sınıf bulunamadı !", type: Model.Enums.ToastrType.Warning));
                    }
                }
            }
            if (model.brandApplicationVisibilty != null && model.brandApplicationVisibilty.companiesListStatus)
            {
                model.companieList = _companiesService.GetCompanyList(_usersService.getUserInformation(_cookieService.getSessionEmail()).userId);
            }
            return(model);
        }
Exemple #6
0
        public PaymentViewModel createAgrement(PaymentViewModel paymentModel)
        {
            if (paymentModel.isAgreement)
            {
                if (paymentModel.creditoreft == "0")
                {// havale eft
                    paymentModel.paymentStatus = PaymentResultsStatusEnum.eftprocessdone;
                    paymentModel.basketGroupId = _countersService.getNewCounter(CounterTypeEnum.agreementCounter);
                    if (makeGroupIdBasketndAgreement(paymentModel))
                    {
                        paymentModel.eftdoneMessage = _defaultValuesService.getDefaultValue("efttamamlandi");
                        paymentModel.bankAccounts   = new BankAccountsListViewModel();
                        paymentModel.bankAccounts.bankAccountsList = _mapper.Map <IList <BankAccountsViewModel> >(_mainContext.bankAccounts.Where(w => w.status == GeneralStatusEnum.Active).ToList());
                        paymentModel.paymentStatus = PaymentResultsStatusEnum.eftprocessdone;
                    }
                    else
                    {
                        paymentModel = getPaymentInformation();
                        ToastrService.AddToUserQueue(new Toastr("İşlem sırasında bir hata oluştu. Lütfen tekrar deneyiniz", type: Model.Enums.ToastrType.Error));
                    }
                }
                else
                {
                    payOnlineCreditCard(paymentModel);
                }
            }
            else
            {
                ToastrService.AddToUserQueue(new Toastr("Lütfen satış sözleşmesini onaylayınız.", type: Model.Enums.ToastrType.Error));
            }

            return(paymentModel);
        }
Exemple #7
0
        public string getUserToken(UsersTokenTypeEnum tokenType, Guid userid)
        {
            UsersToken usersTokenModel = _mainContext.usersTokens.Where(w => w.status == UsersTokenEnum.Active && w.userId == userid && w.type == tokenType).OrderByDescending(o => o.createDate).FirstOrDefault();

            if (usersTokenModel != null && usersTokenModel.tokenId != null)
            {
                return(usersTokenModel.tokenId.ToString());
            }
            else
            {
                ToastrService.AddToUserQueue(new Toastr("Kayıt sırasında bir hata oluştu.", type: Model.Enums.ToastrType.Error));
                return(null);
            }
        }
Exemple #8
0
        public void changeEmailTemplateDetail(EmailTemplatesViewModel model)
        {
            MailTemplates mailTemplatesModel = _mainContext.mailTemplates.Where(w => w.id == model.id).FirstOrDefault();

            mailTemplatesModel.mailContent = model.mailContent;
            mailTemplatesModel.mailHeader  = model.mailHeader;
            if (_mainContext.SaveChanges() == 1)
            {
                ToastrService.AddToUserQueue(new Toastr("Tebrikler e-posta taslağınızı başarıyla güncellediniz.", type: Model.Enums.ToastrType.Success));
            }
            else
            {
                ToastrService.AddToUserQueue(new Toastr("E-posta taslağınızı güncellerken bir hata gerçekleşti.", type: Model.Enums.ToastrType.Error));
            }
        }
Exemple #9
0
        public string createUserToken(UsersTokenTypeEnum tokenType, Guid userid)
        {
            UsersToken usersTokenCreate = new UsersToken();

            usersTokenCreate.createDate = DateTime.Now;
            usersTokenCreate.status     = UsersTokenEnum.Active;
            usersTokenCreate.userId     = userid;
            usersTokenCreate.type       = tokenType;
            _mainContext.usersTokens.Add(usersTokenCreate);
            if (_mainContext.SaveChanges() == 1)
            {
                return(usersTokenCreate.tokenId.ToString());
            }
            else
            {
                ToastrService.AddToUserQueue(new Toastr("Kayıt sırasında bir hata oluştu.", type: Model.Enums.ToastrType.Error));
                return(null);
            }
        }
        public bool checkSaveBasketPossibilty(BrandApplicationViewModel Checkmodel)
        {
            bool result = true;

            Checkmodel.brandApplicationVisibilty = _mapper.Map <BrandApplicationVisibilityViewModel>(_mainContext.brandApplicationVisiblities.Where(w => w.brandApplicationTypesId == Checkmodel.selectedBrandApplication).FirstOrDefault());
            if (Checkmodel.brandApplicationVisibilty.applicationClassStatus)
            {
                if (!(Checkmodel.applicationClassList.applicationClassList.Where(w => w.isSelected).Count() > 0 &&
                      Checkmodel.applicationSubClassList.subList.Where(w => w.isSelected).Count() > 0))
                {
                    ToastrService.AddToUserQueue(new Toastr("Lütfen en az 1 sınıf seçiniz.", type: Model.Enums.ToastrType.Error));
                    result = false;
                }
            }
            if (Checkmodel.brandApplicationVisibilty.brandExplanationStatus)
            {
                if (Checkmodel.explanation == "" || Checkmodel.explanation == null)
                {
                    ToastrService.AddToUserQueue(new Toastr("Lütfen açıklama alanını doldurunuz.", type: Model.Enums.ToastrType.Error));
                    result = false;
                }
            }
            if (Checkmodel.brandApplicationVisibilty.brandNameStatus)
            {
                if (Checkmodel.brandName == "" || Checkmodel.brandName == null)
                {
                    ToastrService.AddToUserQueue(new Toastr("Lütfen marka adını doldurunuz.", type: Model.Enums.ToastrType.Error));
                    result = false;
                }
            }
            if (Checkmodel.brandApplicationVisibilty.companiesListStatus)
            {
                if (Checkmodel.selectedCompany == null || Checkmodel.selectedCompany.Count() == 0)
                {
                    ToastrService.AddToUserQueue(new Toastr("Lütfen en az 1 adet firma seçiniz.", type: Model.Enums.ToastrType.Error));
                    result = false;
                }
            }
            return(result);
        }
Exemple #11
0
        public bool loginUser(string email, string password)
        {
            Users model = _mainContext.users.Where(w => w.status == Model.Enums.UserStatusEnum.Active && w.userEmailAdress == email).FirstOrDefault();

            if (model != null && model.userEmailAdress != null && model.userEmailAdress != "")
            {
                if (model.userPassword == "")
                {
                    ToastrService.AddToUserQueue(new Toastr("Hatalı giriş", type: Model.Enums.ToastrType.Error));
                    return(false);
                }
                else
                {
                    if (checkEmailAdress(model.userEmailAdress) && checkUserPassword(model.userPassword))
                    {
                        if (model.userPassword == password)
                        {
                            ToastrService.AddToUserQueue(new Toastr("Tebrikler , başarıyla giriş yaptınız", type: Model.Enums.ToastrType.Success));
                            return(true);
                        }
                        else
                        {
                            ToastrService.AddToUserQueue(new Toastr("Hatalı giriş", type: Model.Enums.ToastrType.Error));
                            return(false);
                        }
                    }
                    else
                    {
                        ToastrService.AddToUserQueue(new Toastr("Hatalı giriş", type: Model.Enums.ToastrType.Error));
                        return(false);
                    }
                }
            }
            else
            {
                ToastrService.AddToUserQueue(new Toastr("Hatalı giriş", type: Model.Enums.ToastrType.Error));
                return(false);
            }
        }
Exemple #12
0
        public bool checkForgetPassToken(Guid tokenId)
        {
            var userToken = _mainContext.usersTokens.Where(w => w.tokenId == tokenId && w.status == UsersTokenEnum.Active).FirstOrDefault();

            if (userToken != null)
            {
                Guid getUserId = userToken.userId;
                if (getUserToken(UsersTokenTypeEnum.forgetpass, getUserId) == tokenId.ToString())
                {
                    return(true);
                }
                else
                {
                    ToastrService.AddToUserQueue(new Toastr("Şifre sıfırlama talebiniz zaman aşımına uğramıştır.", type: Model.Enums.ToastrType.Error));
                    return(false);
                }
            }
            else
            {
                ToastrService.AddToUserQueue(new Toastr("Şifre sıfırlama talebiniz zaman aşımına uğramıştır.", type: Model.Enums.ToastrType.Error));
                return(false);
            }
        }
 bool checkCreateCompany(CompaniesViewModel model)
 {
     if (model.adress == null || model.companyTitle == null)
     {
         ToastrService.AddToUserQueue(new Toastr("Lütfen adres ve şirket adınızı boş geçmeyiniz.", type: Model.Enums.ToastrType.Warning));
         return(false);
     }
     else
     {
         if (model.companyType == CompaniesTypeEnum.personel)
         {
             if (model.identyNumber.ToString() == null)
             {
                 ToastrService.AddToUserQueue(new Toastr("Lütfen Tc Kimlik numaranızı boş geçmeyiniz.", type: Model.Enums.ToastrType.Warning));
                 return(false);
             }
             else
             {
                 ToastrService.AddToUserQueue(new Toastr("Başarıyla şirket eklediniz.", type: Model.Enums.ToastrType.Success));
                 return(true);
             }
         }
         else
         {
             if (model.taxCenter == null || model.taxNumber.ToString() == null)
             {
                 ToastrService.AddToUserQueue(new Toastr("Lütfen Vergi Dairesi ve Vergi Numaranızı boş geçmeyiniz.", type: Model.Enums.ToastrType.Warning));
                 return(false);
             }
             else
             {
                 ToastrService.AddToUserQueue(new Toastr("Başarıyla şirket eklediniz.", type: Model.Enums.ToastrType.Success));
                 return(true);
             }
         }
     }
 }
Exemple #14
0
        public bool changeRegisterUserPasswordWithEmail(MyAccountViewModel model)
        {
            Users userInformation = _mainContext.users.Where(w => w.userEmailAdress == model.userEmailAdress && w.status == UserStatusEnum.Active).FirstOrDefault();

            if (userInformation != null && model.userPassword == model.userRePassword && model.userActivePassword == userInformation.userPassword && checkUserPassword(model.userPassword))
            {
                userInformation.userPassword = model.userPassword;
                if (_mainContext.SaveChanges() == 1)
                {
                    ToastrService.AddToUserQueue(new Toastr("Şifreniz başarıyla değiştirilmiştir.", type: Model.Enums.ToastrType.Success));
                    return(true);
                }
                else
                {
                    ToastrService.AddToUserQueue(new Toastr("Şifreniz değiştirilirken bir hata ile karşılaşıldı.", type: Model.Enums.ToastrType.Error));
                    return(false);
                }
            }
            else
            {
                ToastrService.AddToUserQueue(new Toastr("Şifreniz değiştirilirken bir hata ile karşılaşıldı.", type: Model.Enums.ToastrType.Error));
                return(false);
            }
        }