public UserModel CreateUser(UserModel model, int numPoints, string description, int? transactionTypeId) { using (var context = new greenMoneyEntities()) { var address = context.Addresses.First(i => i.Id == model.AddressId); var user = new Users1 { Id = model.Id, FirstName = model.FirstName, LastName = model.LastName, Addresses = address, SendEmailOffers = model.SendEmailOffers, SendEmailUpdates = model.SendEmailUpdates, IsFBAccount = model.IsFBAccount, FBUserId = model.FBUserId, IsAdditionalAccountHolder = model.IsAdditionalAccountHolder, Sex = model.Sex, DateOfBirth = model.DateOfBirth, PhoneNumber = model.PhoneNumber }; if (address.Instance_Id != null) user.Instance_Id = (int)address.Instance_Id; // store it context.Users1.Add(user); AddPoints(context, user, numPoints, description, transactionTypeId); context.SaveChanges(); return GetUserById(user.Id); } }
private void AddPoints(greenMoneyEntities context, Users1 user, int numPoints, string description, int? transactionType) { var transaction = new Transactions { Addresses = user.Addresses, Users1 = user, Time = DateTime.Now, Description = description, Points = numPoints, TransactionTypeID = transactionType }; context.Transactions.Add(transaction); }
public UserModel CreateSupplierUser(UserModel model, int numPoints, string description, int? transactionTypeId) { using (var context = new greenMoneyEntities()) { var address = context.Addresses.First(i => i.Id == model.AddressId); var user = new Users1 { Id = model.Id, Instance_Id = model.Instance_Id, FirstName = model.FirstName, LastName = model.LastName, Addresses = address, SendEmailUpdates = model.SendEmailUpdates, IsAdditionalAccountHolder = model.IsAdditionalAccountHolder, BusinessName = model.BusinessName, BusinessNumberABN = model.BusinessNumberABN, BusinessType = model.BusinessType, BussinesWebSite = model.BussinesWebSite, BussinesEmail = model.BussinesEmail, BussinesPhone = model.BussinesPhone, BussinesPhoneArea = model.BussinesPhoneArea, BussinesPhoneMobile = model.BussinesPhoneMobile, BussinesLocation = model.BussinesLocation, EmailBussinesOnVoucherRedeem = model.EmailBussinesOnVoucherRedeem }; // store it context.Users1.Add(user); AddPoints(context, user, numPoints, description, transactionTypeId); context.SaveChanges(); return GetUserById(user.Id); } }