private VolunteerProfileModel ConvertToVolunteerProfileModel(Volunteer volunteer) { VolunteerProfileModel volunteerProfile = new VolunteerProfileModel(); volunteerProfile.volunteerId = volunteer.volunteerId; volunteerProfile.constituentCode = volunteer.constituentCode; volunteerProfile.title = volunteer.title; volunteerProfile.firstName = volunteer.firstName; volunteerProfile.lastName = volunteer.lastName; volunteerProfile.nickName = volunteer.nickName; volunteerProfile.birthday = volunteer.birthday; volunteerProfile.gender = volunteer.gender; volunteerProfile.status = volunteer.status; volunteerProfile.homePhone = volunteer.homePhone; volunteerProfile.cellPhone = volunteer.cellPhone; volunteerProfile.createOn = volunteer.createOn; volunteerProfile.createBy = volunteer.createBy; volunteerProfile.modifiedOn = volunteer.modifiedOn; volunteerProfile.modifiedBy = volunteer.modifiedBy; volunteerProfile.activatedOn = volunteer.activatedOn; volunteerProfile.deactivatedOn = volunteer.deactivatedOn; volunteerProfile.note = volunteer.note; volunteerProfile.token = volunteer.token; volunteerProfile.email = volunteer.email; volunteerProfile.orientation = volunteer.orientation; volunteerProfile.transitPass = volunteer.transitPass; return volunteerProfile; }
private void UpdateVolunteerProfile(VolunteerProfileModel model) { Volunteer target = ConvertVolunteerProfileToVolunteer(model); db.Entry(target).State = EntityState.Modified; db.SaveChanges(); }
public Volunteer CreateNewVolunteer(VolunteerProfileModel model) { Volunteer volunteer = new Volunteer(); volunteer.title = model.title; volunteer.constituentCode = ""; volunteer.firstName = stringToTitleCase(model.firstName); volunteer.lastName = stringToTitleCase(model.lastName); volunteer.nickName = volunteer.firstName + ", " + volunteer.lastName; volunteer.birthday = model.birthday; volunteer.gender = model.gender; volunteer.homePhone = model.homePhone; volunteer.cellPhone = model.cellPhone; volunteer.email = model.email; volunteer.createOn = DateTime.Now; volunteer.status = "Activate"; volunteer.createBy = WebSecurity.CurrentUserName; volunteer.modifiedOn = DateTime.Now; volunteer.modifiedBy = WebSecurity.CurrentUserName; volunteer.activatedOn = DateTime.Now; volunteer.orientation = model.orientation; volunteer.transitPass = model.transitPass; string token = DateTime.Now.ToFileTimeUtc().ToString(); volunteer.token = token; db.Volunteers.Add(volunteer); db.SaveChanges(); return db.Volunteers.Where(v => v.token == token).FirstOrDefault(); }
private Volunteer ConvertVolunteerProfileToVolunteer(VolunteerProfileModel volunteer) { Volunteer target = db.Volunteers.Find(volunteer.volunteerId); // target.volunteerId = volunteer.volunteerId; target.title = volunteer.title; target.firstName = volunteer.firstName; target.lastName = volunteer.lastName; target.nickName = volunteer.nickName; target.birthday = volunteer.birthday; target.gender = volunteer.gender; target.status = volunteer.status; target.homePhone = volunteer.homePhone; target.cellPhone = volunteer.cellPhone; target.email = volunteer.email; // target.createOn = volunteer.createOn; // target.createBy = volunteer.createBy; target.modifiedOn = DateTime.Now; target.modifiedBy = WebSecurity.CurrentUserName; target.activatedOn = volunteer.activatedOn; target.deactivatedOn = volunteer.deactivatedOn; target.orientation = volunteer.orientation; target.transitPass = volunteer.transitPass; // target.note = volunteer.note; // target.token = volunteer.token; return target; }