Example #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);
        }
Example #2
0
        public static List <SalespersonEntity> GetAllSalespeople()
        {
            var users       = UserRepository.Get().GetAppUsers();
            var salespeople = new List <SalespersonEntity>();

            foreach (var user in users)
            {
                var motherFlowerName = string.Empty;
                if (user.MotherFlowerId != null && Guid.Empty != user.MotherFlowerId)
                {
                    motherFlowerName = GetUserById(user.UsuarioId).Name;
                }
                var season = SeasonBusiness.GetSeasonById(user.TemporadaId);
                if (season != null)
                {
                    salespeople.Add(SalespersonEntity.FromUser(user, motherFlowerName, season.Name));
                }
            }
            return(salespeople);
        }
Example #3
0
 public async Task InsertSeason(string name, DateTime startDate, DateTime endDate, bool isActive)
 {
     SeasonBusiness.InsertSeason(name, startDate, endDate, isActive);
 }
Example #4
0
 public SeasonEntity GetCurrentSeason()
 {
     return(SeasonBusiness.GetCurrentSeason());
 }
Example #5
0
 public SeasonModel(string connectionString)
 {
     this.seasonBusiness = new SeasonBusiness(connectionString);
 }