/// <summary> /// Deprecated Method for adding a new object to the customers EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddTocustomers(customer customer) { base.AddObject("customers", customer); }
/// <summary> /// Create a new customer object. /// </summary> /// <param name="idCustomer">Initial value of the idCustomer property.</param> /// <param name="firstName">Initial value of the firstName property.</param> /// <param name="lastName">Initial value of the lastName property.</param> /// <param name="account">Initial value of the account property.</param> /// <param name="cDate">Initial value of the cDate property.</param> public static customer Createcustomer(global::System.String idCustomer, global::System.String firstName, global::System.String lastName, global::System.String account, global::System.String cDate) { customer customer = new customer(); customer.idCustomer = idCustomer; customer.firstName = firstName; customer.lastName = lastName; customer.account = account; customer.cDate = cDate; return customer; }
public ActionResult Register(RegisterModel model) { if (ModelState.IsValid) { // Attempt to register the user MembershipCreateStatus createStatus = MembershipService.CreateUser(model.UserName, model.Password, model.Email); if (createStatus == MembershipCreateStatus.Success) { // On success create a new customer data MembershipUser newUser = MembershipService.GetUser(model.UserName, false); string newUserID = newUser.ProviderUserKey.ToString(); string dtStamp = DateTime.Now.ToString(); string accountNo = Guid.NewGuid().ToString(); var dbATM = new ATMEntities(); var customer = new customer { idCustomer = newUserID, firstName = model.FirstName, lastName = model.LastName, account = accountNo, cDate = dtStamp }; dbATM.customers.AddObject(customer); dbATM.SaveChanges(); FormsService.SignIn(model.UserName, false); Session.Add("accountNumber", accountNo); TempData["justRegistered"] = "Y"; return RedirectToAction("Index", "Home"); } else { ModelState.AddModelError("", CustomerValidation.ErrorCodeToString(createStatus)); } } ViewData["PasswordLength"] = MembershipService.MinPasswordLength; return View(model); }