Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
 public ActionResult EditOrientation(Volunteer volunteer)
 {
     if (ModelState.IsValid)
     {
         Volunteer target = db.Volunteers.Where(v => v.volunteerId == volunteer.volunteerId).FirstOrDefault();
         target.orientation = volunteer.orientation;
         db.Entry(target).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Details/" + volunteer.volunteerId);
     }
     return View(volunteer);
 }
Exemplo n.º 3
0
        private string InsertOrUpdateDatabase(string physicalPath)
        {
            // Return an empty string to signify success
            string result = "";
            IEnumerable<SmsCsvModel> smsModel;
            try
            {
                Volunteer volunteer = new Volunteer();
                CsvContext csv = new CsvContext();

                smsModel = csv.Read<SmsCsvModel>(physicalPath, inputFileDescription);
                SmsCsvModel target;

                foreach (SmsCsvModel item in smsModel)
                {
                    target = checkSMSCsvModel(item);

                    if (target != null)
                    {
                        try
                        {
                            InsertOrUpateVolunteer(target);
                            InsertOrUpateLocation(target);
                            InsertOrUpateEmergencyContact(target);
                        }
                        catch (Exception ex)
                        {
                            result = ex.Message;
                        }

                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            // Return an empty string to signify success
            return result;
        }
Exemplo n.º 4
0
 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();
 }
Exemplo n.º 5
0
        private void InsertOrUpateVolunteer(SmsCsvModel item)
        {
            var v = db.Volunteers.Where(model => model.constituentCode == item.constituentCode);
            if (v.FirstOrDefault() == null)
            {
                // insert into database
                Volunteer volunteer = new Volunteer();
                volunteer.importID = convertNullToString(item.importID);
                volunteer.constituentCode = convertNullToString(item.constituentCode);
                volunteer.title = convertNullToString(item.title);
                volunteer.firstName = convertNullToString(item.firstName);
                volunteer.lastName = convertNullToString(item.lastName);
                volunteer.nickName = "";
                volunteer.birthday = null;
                volunteer.status = "Activate";
                volunteer.gender = convertNullToString(item.gender, "Unknown");
                volunteer.homePhone = convertNullToString(item.homePhone);
                volunteer.cellPhone = convertNullToString(item.cellPhone);
                volunteer.orientation = convertNullToString(item.orientation, "No");
                volunteer.transitPass = convertNullToString(item.transitPass, "N/A");

                volunteer.createOn = DateTime.Now;
                volunteer.createBy = WebSecurity.CurrentUserName;
                volunteer.modifiedOn = DateTime.Now;
                volunteer.modifiedBy = WebSecurity.CurrentUserName;
                volunteer.activatedOn = DateTime.Now;
                // volunteer.deactivatedOn ;
                // volunteer.note;
                // volunteer.token;
                volunteer.email = convertNullToString(item.email);
                db.Volunteers.Add(volunteer);
                db.SaveChanges();
            }
            else
            {
                // update database
                Volunteer volunteer = v.FirstOrDefault();
                volunteer.importID = convertNullToString(item.importID);
                volunteer.title = convertNullToString(item.title);
                volunteer.firstName = convertNullToString(item.firstName);
                volunteer.lastName = convertNullToString(item.lastName);
                volunteer.nickName = "";
                //volunteer.birthday ;
                volunteer.status = "Activate";
                volunteer.gender = convertNullToString(item.gender, "Unknown");
                volunteer.homePhone = convertNullToString(item.homePhone);
                volunteer.cellPhone = convertNullToString(item.cellPhone);
                volunteer.modifiedOn = DateTime.Now;
                volunteer.modifiedBy = WebSecurity.CurrentUserName;
                volunteer.activatedOn = DateTime.Now;
                volunteer.orientation = convertNullToString(item.orientation, "No");
                volunteer.transitPass = convertNullToString(item.transitPass, "N/A");
                // volunteer.deactivatedOn ;
                // volunteer.note;
                // volunteer.token;
                volunteer.email = convertNullToString(item.email);
                db.Entry(volunteer).State = EntityState.Modified;
                db.SaveChanges();
            }
        }