public virtual T Add(T entity) { var entry = dbSet.Add(entity); _context.SaveChanges(); return(entry.Entity); }
public void LogUserCall(User user) { _context.CallLog.Add(new CallLog { UserId = user.UserId, EventDate = DateTime.UtcNow }); _context.SaveChanges(); }
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); }