public ActionResult Login(VolunteerModel vm) { string mainConn = ConfigurationManager.ConnectionStrings["VolunteerConn"].ConnectionString; SqlConnection sqlConn = new SqlConnection(mainConn); string sqlquery = "select UserName,Password from [dbo].[Volunteers] where UserName = @UserName and Password = @Password"; sqlConn.Open(); SqlCommand sqlComm = new SqlCommand(sqlquery, sqlConn); sqlComm.Parameters.AddWithValue("@UserName", vm.UserName); sqlComm.Parameters.AddWithValue("@Password", vm.Password); SqlDataReader sdr = sqlComm.ExecuteReader(); if (sdr.Read()) { Session["UserName"] = vm.UserName.ToString(); return(RedirectToAction("Admin")); } else { ViewData["Message"] = "Invalid Username And Password"; } sqlConn.Close(); return(View()); }
public static List <VolunteerModel> VolunteerDetails(string id) { SqlCommand cmd = null; //initialize command List <VolunteerModel> Terms = new List <VolunteerModel>(); //Create List based on VolunteerModel Model try{ cmd = openConnection(); //Opens SQL connection cmd.CommandText = "SELECT * FROM Volunteer WHERE [Volunteer].VolunteerID = '" + id + "'"; //SQL statement cmd.CommandType = System.Data.CommandType.Text; //Execute statement SqlDataReader rdr = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection); //Create reader based on statement while (rdr.Read() == true) //While there are things left in the reader { VolunteerModel Term = new VolunteerModel(); //Create Term object Term.VolunteerId = Convert.ToInt32(rdr["VolunteerID"].ToString()); //add clientID Term.FName = rdr["FName"].ToString(); //Add first name Term.LName = rdr["LName"].ToString(); //Add Last Name Terms.Add(Term); //Add object to list } } catch (Exception e) //catch any exceptions { throw; } finally{ CloseConnection(cmd); // close DB connection } return(Terms); //return list }
public ActionResult ConfirmVolunteerSlots(VolunteerModel m) { m.UpdateCommitments(); if (m.SendEmail || !m.IsLeader) { List <Person> Staff = null; Staff = DbUtil.Db.StaffPeopleForOrg(m.OrgId); var staff = Staff[0]; var summary = m.Summary(this); var text = Util.PickFirst(m.Setting.Body, "confirmation email body not found"); text = text.Replace("{church}", DbUtil.Db.Setting("NameOfChurch", "church"), true); text = text.Replace("{name}", m.Person.Name, true); text = text.Replace("{date}", DateTime.Now.ToString("d"), true); text = text.Replace("{email}", m.Person.EmailAddress, true); text = text.Replace("{phone}", m.Person.HomePhone.FmtFone(), true); text = text.Replace("{contact}", staff.Name, true); text = text.Replace("{contactemail}", staff.EmailAddress, true); text = text.Replace("{contactphone}", m.Org.PhoneNumber.FmtFone(), true); text = text.Replace("{details}", summary, true); DbUtil.Db.Email(staff.FromEmail, m.Person, m.Setting.Subject, text); DbUtil.Db.Email(m.Person.FromEmail, Staff, "Volunteer Commitments managed", $@"{m.Person.Name} managed volunteer commitments to {m.Org.OrganizationName}<br/> The following Commitments:<br/> {summary}"); } ViewData["Organization"] = m.Org.OrganizationName; SetHeaders(m.OrgId); if (m.IsLeader) { TempData[Fromcalendar] = true; return(View("ManageVolunteer/PickSlots", m)); } return(View("ManageVolunteer/ConfirmVolunteerSlots", m)); }
public ActionResult Update(int id, DateTime?processDate, int statusId, string comments, List <int> approvals) { var m = new VolunteerModel(id); m.Update(processDate, statusId, comments, approvals); return(Redirect("/Volunteering/" + id)); }
public ActionResult Volunteers() { List <VolunteeredEventsModel> volunteers = db.VolunteeredEventsModel.ToList(); List <VolunteerModel> realList = new List <VolunteerModel>(); //adds all volunteers to the model 'realList' //which holds specific information for the reports foreach (var item in volunteers) { VolunteerModel tempVol = new VolunteerModel(); tempVol.userId = item.UserId; tempVol.eventId = item.EventId; tempVol.fullName = item.FullName; try { string eName = db.EventDataModels.Where(a => a.eventId == item.EventId).Select(a => a.eventName).First(); tempVol.eventName = eName; //adds temp volunteer to full list of volunteers realList.Add(tempVol); } catch (Exception e) { } } //reorders the list to sort by event volunteered at realList = realList.OrderBy(a => a.eventName).ToList(); return(View(realList)); }
public ActionResult Submit(VolunteerModel model) { SqlCommand cmd = null; try { cmd = Connect("VolunteerInsert"); cmd.Parameters.Add("@FName", SqlDbType.VarChar, 50).Value = model.FName; cmd.Parameters.Add("@LName", SqlDbType.VarChar, 50).Value = model.LName; cmd.Parameters.Add("@Testimonial", SqlDbType.Bit).Value = model.TestimonialConsent; cmd.Parameters.Add("@Engage", SqlDbType.Bit).Value = model.EngageConsent; cmd.Parameters.Add("@Media", SqlDbType.Bit).Value = model.MediaConsent; cmd.Parameters.Add("@Signature", SqlDbType.VarChar, 50).Value = model.VolunteerSignature; cmd.ExecuteNonQuery(); } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { CloseConnection(cmd); } return(View()); }
public ActionResult ManageVolunteer(string id, int?pid) { if (!id.HasValue()) { return(Content("bad link")); } VolunteerModel m = null; var td = TempData["PeopleId"]; if (td != null) { m = new VolunteerModel(id.ToInt(), td.ToInt()); } else if (pid.HasValue) { var leader = OrganizationMember.VolunteerLeaderInOrg(CurrentDatabase, id.ToInt2()); if (leader) { m = new VolunteerModel(id.ToInt(), pid.Value, true); } } if (m == null) { var guid = id.ToGuid(); if (guid == null) { return(Content("invalid link")); } var ot = CurrentDatabase.OneTimeLinks.SingleOrDefault(oo => oo.Id == guid.Value); if (ot == null) { return(Content("invalid link")); } #if DEBUG2 #else if (ot.Used) { return(Content("link used")); } #endif if (ot.Expires.HasValue && ot.Expires < DateTime.Now) { return(Content("link expired")); } var a = ot.Querystring.Split(','); m = new VolunteerModel(a[0].ToInt(), a[1].ToInt()); id = a[0]; ot.Used = true; CurrentDatabase.SubmitChanges(); } SetHeaders(id.ToInt()); DbUtil.LogActivity($"Pick Slots: {m.Org.OrganizationName} ({m.Person.Name})"); TempData[Fromcalendar] = true; return(View("ManageVolunteer/PickSlots", m)); }
public async Task <IActionResult> Edit(string id, [Bind("Id,FirstName,LastName,PreferredCenters,Skills,Interests,AvailabilityTimes,Address,HomePhone,WorkPhone,CellPhone,Email,EducationBackground,CurrentLicenses,EmergencyContactName,EmergencyContactHomePhone,EmergencyContactWorkPhone,EmergencyContactEmail,EmergencyContactAddress,DriversLicenseOnFile,SsnCardOnFile,ApprovalStatus")] VolunteerModel volunteerModel) { if (id != volunteerModel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(volunteerModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VolunteerModelExists(volunteerModel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(volunteerModel)); }
public async Task <IActionResult> Inventory(bool resolved = false) { InventoryRepository repo = new InventoryRepository(configModel.ConnectionString); VolunteerRepository volunteerRepo = new VolunteerRepository(configModel.ConnectionString); List <InventoryModel> items = null; bool authorized = false; var user = await userManager.GetUserAsync(User); VolunteerModel profile = volunteerRepo.GetVolunteer(user.VolunteerId); // Verify the user has permissions to edit inventory if (User.IsInRole(UserHelpers.UserRoles.Staff.ToString()) || User.IsInRole(UserHelpers.UserRoles.VolunteerCaptain.ToString()) || profile.CanEditInventory) { authorized = true; } else { authorized = false; } if (!authorized) { return(Utilities.ErrorJson("Not authorized")); } // Get the appropriate inventory items items = repo.GetInventory(resolved); return(new JsonResult(new { Error = "", Items = items })); }
public VolunteerController() { apiResponse = new APIResponseModel(); _VolunteerModel = new VolunteerModel(); _VolunteerBs = new VolunteerBs(); _MasjidBs = new MasjidBs(); }
public async Task <IHttpActionResult> PutVolunteer(VolunteerModel volunteer, Guid deviceId) { Volunteer sv = await GetAuthenticatedVolunteerAsync(deviceId); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (sv == null) { return(BadRequest("The specified InterviewerID is not recognized. User not logged in?")); } sv.DeviceId = deviceId; sv.FirstName = volunteer.FirstName; sv.LastName = volunteer.LastName; sv.Email = volunteer.Email; sv.HomePhone = volunteer.HomePhone; sv.MobilePhone = volunteer.MobilePhone; sv.Address.Street = volunteer.Address?.Street; sv.Address.City = volunteer.Address?.City; sv.Address.State = volunteer.Address?.State; sv.Address.ZipCode = volunteer.Address?.ZipCode; db.SaveChanges(); return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Update(int id, DateTime?processDate, int statusId, string comments, List <int> approvals) { var m = new VolunteerModel(id); m.Update(processDate, statusId, comments, approvals); return(RedirectToAction("Index", "Volunteering", new { id = id })); }
public ActionResult AddRole(string id, VolunteerModel volunteer) { var list = new List <string>() { null, "Admin", "Moderator", "Volunteer" }; ViewBag.list = list; var volunteerId = new ObjectId(id); var vol = volunteerCollection.AsQueryable <VolunteerModel>().SingleOrDefault(x => x.Id == volunteerId); var email = vol.Email; try { // TODO: Add update logic here var filter = Builders <VolunteerModel> .Filter.Eq("_id", ObjectId.Parse(id)); if (volunteer.Role == null) { var update = Builders <VolunteerModel> .Update .Set("Active", "No") .Set("Role", volunteer.Role); var result = volunteerCollection.UpdateOne(filter, update); } else { MailAddressModel mode = new MailAddressModel(); mode.To = email; mode.From = Session["Email"].ToString(); mode.Subject = "Hello"; mode.Body = "Hello, your account has been activated!!! Please log in ..."; SendEmail(mode); var update = Builders <VolunteerModel> .Update .Set("Active", "Yes") .Set("Role", volunteer.Role); var result = volunteerCollection.UpdateOne(filter, update); } List <VolunteerModel> volunteers = volunteerCollection.AsQueryable <VolunteerModel>().ToList(); volunteerList = new List <string>(); foreach (var volun in volunteers) { if (volun.Active == "Yes") { volunteerList.Add(volun.Name.ToString()); } } Session["VolunteerList"] = volunteerList; return(RedirectToAction("../Volunteers/Index")); } catch { return(View()); } }
public ActionResult DeleteConfirmed(string id) { VolunteerModel volunteerModel = db.Volunteers.Find(id); db.Volunteers.Remove(volunteerModel); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Update(int id, DateTime?processDate, int statusId, string comments, List <int> approvals, DateTime?mvrDate, int mvrStatusId) { var m = new VolunteerModel(id); m.Update(processDate, statusId, comments, approvals, mvrDate, mvrStatusId); m = new VolunteerModel(id); return(View("Display", m)); }
// GET: LogIn public ActionResult LogIn() { currentTasks = new List <string>(); List <TransportationTaskModel> products = transportationCollection.AsQueryable <TransportationTaskModel>().ToList(); List <InventoryTaskModel> inventory = inventoryCollection.AsQueryable <InventoryTaskModel>().ToList(); List <PhotographyTaskModel> photography = photographyCollection.AsQueryable <PhotographyTaskModel>().ToList(); List <GroomingTaskModel> grooming = groomingCollection.AsQueryable <GroomingTaskModel>().ToList(); List <VetTaskModel> vet = vetCollection.AsQueryable <VetTaskModel>().ToList(); List <OtherTaskModel> others = otherCollection.AsQueryable <OtherTaskModel>().ToList(); foreach (var product in products) { currentTasks.Add(product.Id.ToString()); } foreach (var groom in grooming) { currentTasks.Add(groom.Id.ToString()); } foreach (var inv in inventory) { currentTasks.Add(inv.Id.ToString()); } foreach (var photo in photography) { currentTasks.Add(photo.Id.ToString()); } foreach (var v in vet) { currentTasks.Add(v.Id.ToString()); } foreach (var ot in others) { currentTasks.Add(ot.Id.ToString()); } Session["TaskCount"] = currentTasks.Count().ToString(); List <VolunteerModel> volunteers = volunteerCollection.AsQueryable <VolunteerModel>().ToList(); bool isEmpty = !volunteers.Any(); if (isEmpty) { VolunteerModel logIn = new VolunteerModel(); logIn.Email = "*****@*****.**"; logIn.Name = "Test"; logIn.Role = "Admin"; logIn.Password = "******"; logIn.ConfirmPassword = "******"; logIn.UserPhoto = "/UserImages/default-user-image.png"; logIn.Active = "Yes"; volunteerCollection.InsertOne(logIn); } return(View()); }
public ActionResult ManageVolunteer(string id, int?pid) { if (!id.HasValue()) { return(Content("bad link")); } VolunteerModel m = null; var td = TempData["ps"]; if (td != null) { m = new VolunteerModel(orgId: id.ToInt(), peopleId: td.ToInt()); } else if (pid.HasValue) { var leader = OrganizationModel.VolunteerLeaderInOrg(id.ToInt2()); if (leader) { m = new VolunteerModel(orgId: id.ToInt(), peopleId: pid.Value, leader: true); } } if (m == null) { var guid = id.ToGuid(); if (guid == null) { return(Content("invalid link")); } var ot = DbUtil.Db.OneTimeLinks.SingleOrDefault(oo => oo.Id == guid.Value); if (ot == null) { return(Content("invalid link")); } #if DEBUG2 #else if (ot.Used) { return(Content("link used")); } #endif if (ot.Expires.HasValue && ot.Expires < DateTime.Now) { return(Content("link expired")); } var a = ot.Querystring.Split(','); m = new VolunteerModel(orgId: a[0].ToInt(), peopleId: a[1].ToInt()); id = a[0]; ot.Used = true; DbUtil.Db.SubmitChanges(); } SetHeaders(id.ToInt()); DbUtil.LogActivity("Pick Slots: {0} ({1})".Fmt(m.Org.OrganizationName, m.Person.Name)); return(View(m)); }
public ActionResult Edit([Bind(Include = "Email,FirstName,LastName,Username,Password,Center,Interests,Availability,Address,PhoneNumber,Education,Licenses,EMCname,EMCphone,EMCemail,EMCaddress,DriversLicenseOnFile,SocialCardOnFile,ApprovalStatus")] VolunteerModel volunteerModel) { if (ModelState.IsValid) { db.Entry(volunteerModel).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(volunteerModel)); }
public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,PreferredCenters,Skills,Interests,AvailabilityTimes,Address,HomePhone,WorkPhone,CellPhone,Email,EducationBackground,CurrentLicenses,EmergencyContactName,EmergencyContactHomePhone,EmergencyContactWorkPhone,EmergencyContactEmail,EmergencyContactAddress,DriversLicenseOnFile,SsnCardOnFile,ApprovalStatus")] VolunteerModel volunteerModel) { if (ModelState.IsValid) { _context.Add(volunteerModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(volunteerModel)); }
public ActionResult MembersDetail() { VolunteerModel db = new VolunteerModel(); VolunteerLeader db1 = new VolunteerLeader(); var volunteer_detail = db.GetAllVolunteer(Convert.ToInt32(Session["UserID"])); ViewBag.expertises = db.GetVolunteerExpertise(Convert.ToInt32(Session["UserID"])); ViewBag.leaders = db1.GetVolunteerLeader(Convert.ToInt32(Session["UserID"])); ViewBag.group = db.GetVolunteerGroup(Convert.ToInt32(Session["UserID"])); return(View(volunteer_detail)); }
public Volunteer(VolunteerModel item) { Id = item.Id; Name = item.Name; Email = item.Email; Contact = item.Contact; CreatedDate = Convert.ToDateTime(item.CreatedDate); ZoneId = item.ZoneId; Skills = item.Skills; Occupation = item.Occupation; VolunteerFor = item.VolunteerFor; }
/// <summary> /// Update the item in the data store /// use the ID from the item passed in to find the item and then update it /// </summary> /// <param name="data">the item to update</param> /// <returns>the updated item</returns> public VolunteerModel Update(VolunteerModel data) { var myData = Read(data.ID); if (myData == null) { return(null); } myData.Update(data); return(data); }
/// <summary> /// Saves the volunteer profile. /// </summary> /// <param name="volunteer">The volunteer profile.</param> /// <returns> /// A task to await the save operation. /// </returns> public static Task SaveVolunteerAsync(VolunteerModel volunteer) { var parameters = new Dictionary <string, string> { { "deviceId", UserSettings.VolunteerId }, }; using (new LatencyMetric("SaveVolunteer")) { return(ApiClient.InvokeApiAsync("Volunteers", JObject.FromObject(volunteer), HttpMethod.Put, parameters)); } }
public ActionResult Edit(int id, VolunteerModel vmodel) { try { VolunteerDBhandle sdb = new VolunteerDBhandle(); sdb.UpdateDetails(vmodel); return(RedirectToAction("Index")); } catch { return(View()); } }
// GET: Volunteers/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } VolunteerModel volunteerModel = db.Volunteers.Find(id); if (volunteerModel == null) { return(HttpNotFound()); } return(View(volunteerModel)); }
public int Save(VolunteerModel model) { Volunteer _volunteer = new Volunteer(model); if (model.Id != null && model.Id != 0) { _Volunteer.Update(_volunteer); } else { _volunteer.CreatedDate = System.DateTime.Now; _Volunteer.Insert(_volunteer); } return(_volunteer.Id); }
public async Task <IActionResult> InventoryEdit(InventoryModel model) { InventoryRepository repo = new InventoryRepository(configModel.ConnectionString); VolunteerRepository volunteerRepo = new VolunteerRepository(configModel.ConnectionString); InventoryModel dbModel = null; bool authorized = false; var user = await userManager.GetUserAsync(User); VolunteerModel profile = volunteerRepo.GetVolunteer(user.VolunteerId); // Verify the user has permissions to edit inventory if (User.IsInRole(UserHelpers.UserRoles.Staff.ToString()) || User.IsInRole(UserHelpers.UserRoles.VolunteerCaptain.ToString()) || profile.CanEditInventory) { authorized = true; } else { authorized = false; } if (!authorized) { return(Utilities.ErrorJson("Not authorized")); } // Check that the inputs are all valid if (string.IsNullOrEmpty(model.Name)) { return(Utilities.ErrorJson("Name must be included")); } if (model.Count < 0) { return(Utilities.ErrorJson("Count must be a non-negative integer")); } dbModel = repo.GetInventoryItem(model.Id); if (dbModel == null) { return(Utilities.ErrorJson("Invalid id")); } // Send to database repo.UpdateInventory(model.Id, model.Name, model.Count, model.Resolved); return(Utilities.NoErrorJson()); }
public async Task <IActionResult> VolunteerProfileEdit(VolunteerModel volunteer) { var user = await userManager.GetUserAsync(User); VolunteerRepository repo = new VolunteerRepository(configModel.ConnectionString); VolunteerModel currentModel = repo.GetVolunteer(volunteer.Id); // Return with an error if there is no volunteer model to update or if the profile being updated is not that of the logged-in user if (currentModel == null) { return(Utilities.ErrorJson("Profile does not exist")); } if (currentModel.Email != user.UserName) { return(Utilities.ErrorJson("Not authorized to edit this profile")); } // Update the volunteer's languages, if any were provided if (volunteer.Languages != null && volunteer.Languages.Length != 0) { try { repo.UpdateLanguages(volunteer.Id, volunteer.Languages); } catch (Exception e) { return(Utilities.ErrorJson(e.Message)); } } // Update the volunteer's profile try { repo.UpdateVolunteerProfile(volunteer); } catch (Exception e) { return(Utilities.ErrorJson(e.Message)); } // We want to make sure we return the most up-to-date information return(new JsonResult(new { Volunteer = repo.GetVolunteer(volunteer.Id), Error = "" })); }
public ActionResult Create(VolunteerModel volunteer) { var vol = volunteerCollection.AsQueryable <VolunteerModel>().SingleOrDefault(x => x.Email == volunteer.Email); if (vol == null) { volunteer.UserPhoto = "/UserImages/default-user-image.png"; volunteer.Active = "No"; // TODO: Add insert logic here volunteerCollection.InsertOne(volunteer); return(RedirectToAction("Details", new { id = volunteer.Id })); } else { ViewBag.Message = "The account with the entered Email Address has already been registered click Forget Password to Recover your password "; return(View()); } }
public static VolunteerModel ConvertToModel(Volunteer Volunteer) { VolunteerModel model = new VolunteerModel() { FirstName = Volunteer.FirstName, LastName = Volunteer.LastName, Email = Volunteer.Email, HomePhone = Volunteer.HomePhone, MobilePhone = Volunteer.MobilePhone }; model.Address.Street = Volunteer.Address.Street; model.Address.City = Volunteer.Address.City; model.Address.State = Volunteer.Address.State; model.Address.ZipCode = Volunteer.Address.ZipCode; return(model); }
public ActionResult VolunteerApprovals(VolunteerModel m) { return View("Ministry/Volunteer", m); }