Beispiel #1
0
 public EmergencyContact CreateContactForNewVolunteer(VolunteerContactModel model)
 {
     EmergencyContact contact = new EmergencyContact();
     contact.volunteerId = model.volunteerId;
     contact.contactName = stringToTitleCase(model.contactName);
     contact.relationship = model.relationship;
     contact.emergencyPhone = model.emergencyPhone;
     contact.comment = model.comment;
     contact.createDate = DateTime.Now;
     db.EmergencyContacts.Add(contact);
     db.SaveChanges();
     return db.EmergencyContacts.Where(e => e.volunteerId == contact.volunteerId).FirstOrDefault();
 }
Beispiel #2
0
 public ActionResult Contact_Destroy([DataSourceRequest] DataSourceRequest request, VolunteerContactModel model)
 {
     EmergencyContact target = db.EmergencyContacts.Find(model.contactId);
     db.EmergencyContacts.Remove(target);
     db.SaveChanges();
     return Json(ModelState.ToDataSourceResult());
 }
Beispiel #3
0
 private void UpdateContact(VolunteerContactModel model)
 {
     if (model != null && ModelState.IsValid)
     {
         {
             var target = db.EmergencyContacts.Find(model.contactId);
             target.volunteerId = model.volunteerId;
             target.contactName = model.contactName;
             target.relationship = model.relationship;
             target.emergencyPhone = model.emergencyPhone;
             target.comment = model.comment;
             db.Entry(target).State = EntityState.Modified;
             db.SaveChanges();
         }
     }
 }
Beispiel #4
0
        public ActionResult Contact_Create([DataSourceRequest] DataSourceRequest request, VolunteerContactModel model)
        {
            int id = 0;
            var session = HttpContext.Session;
            if (session != null)
            {
                if (session["VolunteerId"] != null)
                {
                    id = int.Parse(session["VolunteerId"].ToString());
                }
            }

            if (model != null)
            {
                EmergencyContact target = new EmergencyContact();

                if (db.EmergencyContacts.Where(m => m.contactId == model.contactId).FirstOrDefault() == null)
                {
                    target.volunteerId = id;
                    target.contactName = model.contactName;
                    target.relationship = model.relationship;
                    target.emergencyPhone = model.emergencyPhone;
                    target.comment = model.comment;
                    db.EmergencyContacts.Add(target);
                    db.SaveChanges();
                }
            }
            return Json(ModelState.ToDataSourceResult());
        }
Beispiel #5
0
        private void CreateContact(VolunteerContactModel model)
        {
            if (model != null)
            {
                EmergencyContact target = new EmergencyContact();

                if (db.EmergencyContacts.Where(m => m.contactId == model.contactId).FirstOrDefault() == null)
                {
                    target.volunteerId = model.volunteerId;
                    target.contactName = model.contactName;
                    target.relationship = model.relationship;
                    target.emergencyPhone = model.emergencyPhone;
                    target.comment = model.comment;
                    db.EmergencyContacts.Add(target);
                    db.SaveChanges();
                }
            }
        }