// Helper methods for creating user objects from a data reader. private User ReadUserRow(SqlDataReader reader) { User user = null; // UserType is a discriminator column on the user table. string userType = reader.Field <string>("UserType"); if (userType == AccountTypes.CONSULTANT) { var consultant = new Consultant(); consultant.IsOnBeach = reader.Field <bool>("IsOnBeach"); user = consultant; } else if (userType == AccountTypes.ACCOUNT_EXECUTIVE) { user = new AccountExecutive(); } user.Id = reader.Field <int>("Id"); user.EmailAddress = reader.Field <string>("EmailAddress"); user.FirstName = reader.Field <string>("FirstName"); user.LastName = reader.Field <string>("LastName"); user.PhoneNumber = new PhoneNumber(reader.Field <string>("PhoneNumber")); user.Password = new HashedPassword(); user.Password.Hash = reader.Field <string>("Password_Hash"); user.Password.Salt = reader.Field <string>("Password_Salt"); return(user); }
public async Task <IActionResult> Edit(string id, [Bind("accountExecutiveId,accountExecutiveName,description,phone,email,street1,street2,city,province,country,systemUserId,createdAt")] AccountExecutive accountExecutive) { if (id != accountExecutive.accountExecutiveId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(accountExecutive); await _context.SaveChangesAsync(); } catch (Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException) { if (!AccountExecutiveExists(accountExecutive.accountExecutiveId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(accountExecutive)); }
public async Task <IActionResult> Create([Bind("accountExecutiveId,accountExecutiveName,description,phone,email,street1,street2,city,province,country,systemUserId,createdAt")] AccountExecutive accountExecutive) { if (ModelState.IsValid) { _context.Add(accountExecutive); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(accountExecutive)); }