コード例 #1
0
        public static UserEntity RegisterUser(string email, string password, string name,
                                              string primaryTelephone, string secundaryTelephone, string cpf, UserType userType, string cep,
                                              int AverageTicketPoints, int RegisterClientsPoints, int salesNumberPoints, int averageTtensPerSalepoints,
                                              int inviteAllyFlowersPoints, Guid temporadaId, Guid motherFlowerId, bool isActive, DateTime birthday)
        {
            if (String.IsNullOrEmpty(email) || String.IsNullOrEmpty(password) || String.IsNullOrEmpty(name) ||
                String.IsNullOrEmpty(primaryTelephone) || String.IsNullOrEmpty(cpf))
            {
                throw new ExceptionWithHttpStatus(System.Net.HttpStatusCode.BadRequest, Messages.OBRIGATORY_DATA_MISSING);
            }
            EmailValidator.IsValidEmail(email);

            var oldUser = UserRepository.Get().GetUserByEmail(email);

            if (oldUser != null)
            {
                throw new ExceptionWithHttpStatus(System.Net.HttpStatusCode.BadRequest, Messages.EMAIL_ALREADY_USED);
            }

            var currentSeason = SeasonBusiness.GetCurrentSeason();

            var cryptoPassword = EncryptPassword(password);
            var newUserId      = Guid.NewGuid();

            UserRepository.Get().InsertUser(newUserId, email, cryptoPassword.Password, cryptoPassword.Salt, name, primaryTelephone,
                                            secundaryTelephone, cpf, userType, cep, AverageTicketPoints, RegisterClientsPoints, salesNumberPoints, averageTtensPerSalepoints,
                                            inviteAllyFlowersPoints, currentSeason.TemporadaId, motherFlowerId, isActive, birthday);
            var newUser = UserRepository.Get().GetUserById(newUserId);

            if (newUser == null)
            {
                throw new ExceptionWithHttpStatus(System.Net.HttpStatusCode.BadRequest, Messages.USER_REGISTRATION_ERROR);
            }
            return(newUser);
        }
コード例 #2
0
ファイル: SeasonService.cs プロジェクト: lucas-mv/pottiRoma
 public SeasonEntity GetCurrentSeason()
 {
     return(SeasonBusiness.GetCurrentSeason());
 }