Esempio n. 1
0
        public virtual T Add(T entity)
        {
            var entry = dbSet.Add(entity);

            _context.SaveChanges();
            return(entry.Entity);
        }
Esempio n. 2
0
        public void LogUserCall(User user)
        {
            _context.CallLog.Add(new CallLog
            {
                UserId    = user.UserId,
                EventDate = DateTime.UtcNow
            });

            _context.SaveChanges();
        }
Esempio n. 3
0
        public User AddNewuser(UserSignupModel signupModel, StandardPricingTier tier, string userName)
        {
            var apiToken = Guid.NewGuid();

            var passwordBytes = Encoding.ASCII.GetBytes(signupModel.Password);
            var password      = _passwordHelper.GenerateSecurePassword(passwordBytes);

            var user = new User
            {
                ApiToken                 = apiToken,
                CallsPerMonth            = tier.CallsPerMonth,
                CanCallApi               = true,
                FirstName                = signupModel.FirstName,
                LastName                 = signupModel.LastName,
                Email                    = signupModel.EmailAddress,
                PricePerMonth            = tier.PricePerMonth,
                Password                 = password,
                CreatedBy                = userName,
                CreatedDate              = DateTime.UtcNow,
                UpdatedBy                = userName,
                CreditCardNumber         = !string.IsNullOrEmpty(signupModel.CreditCardNumber) ? long.Parse(signupModel.CreditCardNumber) : default(decimal?),
                CreditCardCvcCode        = signupModel.CreditCardCvcCode,
                CreditCardExpirationDate = signupModel.CreditCardExpirationDate,
                UpdatedDate              = DateTime.UtcNow,
                AddressLine1             = signupModel.AddressLine1,
                AddressLine2             = signupModel.AddressLine2,
                City    = signupModel.City,
                State   = signupModel.State,
                ZipCode = signupModel.ZipCode
            };

            _context.User.Add(user);
            _context.SaveChanges();

            return(user);
        }