public EditMemberViewModel(Member member) { Init(); Id = member.Id; AddressLine_1 = member.AddressLine_1; AddressLine_2 = member.AddressLine_2; AltPhone = member.AltPhone; City = member.City; EmergencyName = member.EmergencyName; EmergencyPhone = member.EmergencyPhone; LastMedical = member.LastMedical; LastName = member.LastName; FirstName = member.FirstName; MemberSince = member.MemberSince; Phone = member.Phone; //PrimaryEmail = member.PrimaryEmail; RetractHours = member.RetractHours; //SecondaryEmail = member.SecondaryEmail; Status = member.Status; State = member.State; TotalHours = member.TotalHours; Zip = member.Zip; }
public static Member CopyToEntity(this EditMemberViewModel model, Member member) { member.FirstName = model.FirstName; member.LastName = model.LastName; member.AddressLine_1 = model.AddressLine_1; member.AddressLine_2 = model.AddressLine_2; member.AltPhone = model.AltPhone; member.City = model.City; member.EmergencyName = model.EmergencyName; member.EmergencyPhone = model.EmergencyPhone; member.LastMedical = model.LastMedical; member.Phone = model.Phone; //member.PrimaryEmail = model.PrimaryEmail; member.RetractHours = model.RetractHours; //member.SecondaryEmail = model.SecondaryEmail; member.MemberSince = model.MemberSince; member.TotalHours = model.TotalHours; member.Zip = model.Zip; return member; }
public static Member ConvertToEntity(this EditMemberViewModel model) { Member member = new Member(); return model.CopyToEntity(member); }
private PilotReviewViewModel InitializePilotReviewViewModel(Member member) { PilotReviewViewModel pilotVM = new PilotReviewViewModel() { MemberId = member.Id, PilotName = member.FullName, AircraftCheckouts = new List<AircraftCheckoutViewModel>() }; pilotVM.FlightReview = new FlightReviewViewModel(); if (member.FlightReviews != null && member.FlightReviews.Count > 0) { FlightReview review = member.FlightReviews.OrderByDescending(r => r.Date).First(); pilotVM.FlightReview.ReviewDate = review.Date;//ToString("MMMM dd, yyyy"); pilotVM.FlightReview.InstructorName = review.InstructorName; pilotVM.FlightReview.Notes = review.InstructorNotes; pilotVM.FlightReview.RetractTime = review.RetractTime; pilotVM.FlightReview.TotalTime = review.TotalTime; pilotVM.FlightReview.ReviewType = review.ReviewType; //pilotVM.FlightReview.I = member.FlightReviews.First().Id; } foreach (var pilotCheckout in member.Checkouts) { AircraftCheckoutViewModel checkoutVM = new AircraftCheckoutViewModel(); checkoutVM.Id = pilotCheckout.Id; checkoutVM.AircraftId = pilotCheckout.AircraftId; Aircraft aircraft = _dataService.GetAircraftById(pilotCheckout.AircraftId); checkoutVM.RegistrationNumber = aircraft.RegistrationNumber; checkoutVM.CheckoutDate = pilotCheckout.CheckoutDate; checkoutVM.InstructorId = pilotCheckout.InstructorId; var instructor = _dataService.GetMember(pilotCheckout.InstructorId); checkoutVM.InstructorName = instructor.FullName; pilotVM.AircraftCheckouts.Add(checkoutVM); } if(member.StageChecks != null) pilotVM.StageChecks = member.StageChecks.OrderBy(s => s.Date).ToList(); return pilotVM; }
public void UpdateMember(Member member) { member.LastUpdated = DateTime.Now; _repository.Attach(member); _repository.UnitOfWork.SaveChanges(); }
public void ImportUsers() { IEnumerator<NtfcDataSet.LoginRow> srcLogins = _dataSet.Login.GetEnumerator(); while (srcLogins.MoveNext()) { var srcLogin = srcLogins.Current; NtfcDataSet.MembershipRow srcMember = _dataSet.Membership.FirstOrDefault(r => r.Member_ID == srcLogin.Member_ID); // drop members that don't have logins if (srcMember == null) { Debug.WriteLine("Member " + srcLogin.Member_ID + " not found."); continue; } if (srcMember.IsFirst_NameNull()) continue; if (srcMember.First_Name.Trim() == String.Empty || srcMember.First_Name.Contains("--")) continue; //if (!srcMember.Status) // continue; Login login = new Login(); login.MemberPIN = srcLogin.Member_ID.ToString(); string username = (srcMember.First_Name.Trim() + srcMember.Last_Name.Trim()).ToLower(); username = Regex.Replace(username, @"[\W]", String.Empty); login.Username = username; login.PasswordSalt = SimpleHash.GetSalt(32); login.Password = SimpleHash.MD5(srcLogin.Login_Password, login.PasswordSalt); login.FirstName = srcMember.First_Name; login.LastName = srcMember.Last_Name; login.Email = !srcMember.IsEmailNull() ? srcMember.Email : null; login.Email2 = !srcMember.Isemail2Null() ? srcMember.email2 : null; Member member = new Member(); if (srcMember.Status) member.Status = MemberStatus.Active.ToString(); else member.Status = MemberStatus.Removed.ToString(); member.AddressLine_1 = !srcMember.IsAddressNull() ? srcMember.Address : null; member.Phone = !srcMember.IsHome_PhoneNull() ? srcMember.Home_Phone : null; member.AltPhone = !srcMember.IsWork_PhoneNull() ? srcMember.Work_Phone : null; member.City = !srcMember.IsCityNull() ? srcMember.City : null; member.State = !srcMember.IsStateNull() ? srcMember.State : null; member.Zip = !srcMember.IsZipNull() ? srcMember.Zip : null; //member.PrimaryEmail = !srcMember.IsEmailNull() ? srcMember.Email : null; //member.SecondaryEmail = !srcMember.Isemail2Null() ? srcMember.email2 : null; member.EmergencyName = !srcMember.IsE_First_NameNull() ? srcMember.E_First_Name + " " + srcMember.E_Last_Name : null; member.EmergencyPhone = !srcMember.IsE_Home_PhoneNull() ? srcMember.E_Home_Phone : null; member.FirstName = srcMember.First_Name; member.LastName = srcMember.Last_Name; member.LastMedical = !srcMember.IsMedical_DateNull() ? (DateTime?)srcMember.Medical_Date : null; member.MemberSince = srcMember.Membership_Date; if (!srcMember.IsBirthdateNull()) { DateTime dob = DateTime.MinValue; if (DateTime.TryParse(srcMember.Birthdate, out dob)) member.BirthDate = dob; } member.LastUpdated = srcMember.Last_Update; member.PilotStatus = !srcMember.IsPilot_statusNull() ? srcMember.Pilot_status : null; member.Roles = new List<Role>(); member.Roles.Add(_dbContext.Roles.First(r => r.Id == 5)); if (login.MemberPIN == "547" || login.MemberPIN == "615") member.Roles.Add(_dbContext.Roles.First(r => r.Id == 1)); //Role instructorRole = _dbContext.Roles.First(r => r.Name.Contains("Instructor")); //if(login.OldMemberId == "703" || // login.OldMemberId == "587" || // login.OldMemberId == "199" || // login.OldMemberId == "296" || // login.OldMemberId == "359" || // login.OldMemberId == "655" || // login.OldMemberId == "727" || // login.OldMemberId == "618") //{ // member.Roles.Add(instructorRole); //} login.ClubMember = new List<Member>(); login.ClubMember.Add(member); _dbContext.Logins.Add(login); //_dbContext.Members.Add(member); // insert into forum database //User user = new User(); //user.password = srcLogin.Login_Password; //using (ExternalDbContext db = new ExternalDbContext()) //{ // db.Users.Add(user); // db.SaveChanges(); // string sqlCommand = String.Format("INSERT INTO `vb3_userfield` (userid) VALUES({0})", user.userid); // db.Database.ExecuteSqlCommand(sqlCommand); // db.SaveChanges(); // string sqlCommand2 = String.Format("INSERT INTO `vb3_useractivation` (userid, activationid) VALUES({0},'test')", user.userid); // db.Database.ExecuteSqlCommand(sqlCommand2); // db.SaveChanges(); //} } _dbContext.SaveChanges(); }