// Creates a new instance of UserAccount. public void CreateUserAccount(string firstName, string lastName, UserAccount.Genders gender, string course, string branch, string collegeName, string userId) { var userAccount = new UserAccount { FirstName = firstName, LastName = lastName, Gender = gender, Course = course, Branch = branch, CollegeName = collegeName, ApplicationUserId = userId }; db.UserAccounts.Add(userAccount); db.SaveChanges(); }
// Service to create a new UserAccount without view. public void CreateUserAccount(string firstName, string lastName, decimal mobile, UserAccount.Genders gender, string userId) { try { var userAccount = new UserAccount { FirstName = firstName, LastName = lastName, Mobile = mobile, Gender = gender, Balance = (decimal)0, // Initial balance of any user is 0. ApplicationUserId = userId }; db.UserAccounts.Add(userAccount); db.SaveChanges(); } catch (DbEntityValidationException e) { throw; } }