public ActionResult VolunteerAllocation(string id, int page, string searching)
 {
     try
     {
         page         = UniversalFunctions.GetCurrentPage(page);
         ViewBag.Page = page;
         List <Volunteer> volunteers = volunteerManager.GetListOfVolunteers();
         volunteers      = VolunteerFunctions.GetVolunteerAfterSorting(volunteers, "Active_desc");
         ViewBag.counter = volunteers.Count();
         int nrofdocs = UniversalFunctions.GetNumberOfItemPerPageFromSettings(TempData);
         ViewBag.nrofdocs = nrofdocs;
         string stringofids = VolunteerFunctions.GetStringOfIds(volunteers);
         ViewBag.stringofids = stringofids;
         volunteers          = VolunteerFunctions.GetVolunteersAfterPaging(volunteers, page, nrofdocs);
         List <Event> events = eventManager.GetListOfEvents();
         ViewBag.strname   = EventFunctions.GetAllocatedVolunteersString(events, id);
         ViewBag.Eventname = EventFunctions.GetNameOfEvent(events, id);
         ViewBag.Evid      = id;
         volunteers        = VolunteerFunctions.GetVolunteersAfterSearching(volunteers, searching);
         return(View(volunteers));
     }
     catch
     {
         return(RedirectToAction("Localserver", "Home"));
     }
 }
 public ActionResult Birthday()
 {
     try
     {
         List <Volunteer> volunteers = volunteerManager.GetListOfVolunteers();
         volunteers = VolunteerFunctions.GetVolunteersWithBirthdays(volunteers);
         return(View(volunteers));
     }
     catch
     {
         return(RedirectToAction("Localserver", "Home"));
     }
 }
        public ActionResult FileUpload(IFormFile Files)
        {
            try
            {
                List <Volunteer> volunteers = volunteerManager.GetListOfVolunteers();
                int docsimported            = 0;
                if (UniversalFunctions.File_is_not_empty(Files))
                {
                    string path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", Files.FileName);
                    UniversalFunctions.CreateFileStream(Files, path);
                    List <string[]> volunteersasstring = CSVImportParser.GetListFromCSV(path);
                    if (CSVImportParser.DefaultVolunteerCSVFormat(path))
                    {
                        for (int i = 0; i < volunteersasstring.Count; i++)
                        {
                            Volunteer volunteer = new Volunteer();
                            volunteer = VolunteerFunctions.GetVolunteerFromString(volunteersasstring[i]);

                            if (VolunteerFunctions.DoesNotExist(volunteers, volunteer))
                            {
                                docsimported++;
                                volunteerManager.AddVolunteerToDB(volunteer);
                            }
                        }
                    }
                    else
                    {
                        for (int i = 0; i < volunteersasstring.Count; i++)
                        {
                            Volunteer volunteer = new Volunteer();
                            volunteer = VolunteerFunctions.GetVolunteerFromOtherString(volunteersasstring[i]);
                            if (VolunteerFunctions.DoesNotExist(volunteers, volunteer))
                            {
                                docsimported++;
                                volunteerManager.AddVolunteerToDB(volunteer);
                            }
                        }
                    }
                    UniversalFunctions.RemoveTempFile(path);
                    return(RedirectToAction("ImportUpdate", "Home", new { docsimported }));
                }
                else
                {
                    return(View());
                }
            }
            catch
            {
                return(RedirectToAction("IncorrectFile", "Home"));
            }
        }
        public ActionResult CSVSaver(bool All, bool Name, bool Birthdate, bool Address, bool Gender, bool Desired_Workplace, bool CNP, bool Field_of_Activity, bool Occupation, bool CI_Info, bool Activity, bool Hour_Count, bool Contact_Information, bool Additional_info)
        {
            string IDS = HttpContext.Session.GetString(VolMongoConstants.SECONDARY_SESSION_KEY_VOLUNTEER);

            HttpContext.Session.Remove(VolMongoConstants.SECONDARY_SESSION_KEY_VOLUNTEER);
            string ids_and_fields = VolunteerFunctions.GetIdAndFieldString(IDS, All, Name, Birthdate, Address, Gender, Desired_Workplace, CNP, Field_of_Activity, Occupation, CI_Info, Activity, Hour_Count, Contact_Information, Additional_info);
            string key1           = VolMongoConstants.VOLUNTEERSESSION;
            string header         = ControllerHelper.GetHeaderForExcelPrinterVolunteer(_localizer);
            string key2           = VolMongoConstants.VOLUNTEERHEADER;

            ControllerHelper.CreateDictionaries(key1, key2, ids_and_fields, header);
            string csvexporterlink = "csvexporterapp:" + key1 + ";" + key2;

            return(Redirect(csvexporterlink));
        }
 public ActionResult VolunteerAllocation(string[] volunteerids, string Evid)
 {
     try
     {
         List <Volunteer> volunteers = volunteerManager.GetListOfVolunteers();
         volunteers = VolunteerFunctions.GetVolunteersByIds(volunteers, volunteerids);
         Event  eventtoallocateto = eventManager.GetOneEvent(Evid);
         string nameofvolunteers  = VolunteerFunctions.GetVolunteerNames(volunteers);
         eventtoallocateto.AllocatedVolunteers       = nameofvolunteers;
         eventtoallocateto.NumberAllocatedVolunteers = EventFunctions.VolunteersAllocatedCounter(nameofvolunteers);
         eventManager.UpdateAnEvent(eventtoallocateto, Evid);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(RedirectToAction("Localserver", "Home"));
     }
 }
        public ActionResult Index(string searchedFullname, string searchedContact, string sortOrder, bool Active, bool HasCar, bool HasDrivingLicence, DateTime lowerdate, DateTime upperdate, int page, string gender, string searchedAddress, string searchedworkplace, string searchedOccupation, string searchedRemarks, int searchedHourCount)
        {
            try
            {
                int nrofdocs = UniversalFunctions.GetNumberOfItemPerPageFromSettings(TempData);
                List <Volunteer> volunteers = volunteerManager.GetListOfVolunteers();
                volunteers      = VolunteerFunctions.GetVolunteersAfterFilters(volunteers, searchedFullname, searchedContact, Active, HasCar, HasDrivingLicence, lowerdate, upperdate, gender, searchedAddress, searchedworkplace, searchedOccupation, searchedRemarks, searchedHourCount);
                ViewBag.counter = volunteers.Count();
                string stringofids = VolunteerFunctions.GetStringOfIds(volunteers);
                volunteers = VolunteerFunctions.GetVolunteerAfterPaging(volunteers, page, nrofdocs);
                volunteers = VolunteerFunctions.GetVolunteerAfterSorting(volunteers, sortOrder);
                string key = VolMongoConstants.SESSION_KEY_VOLUNTEER;
                HttpContext.Session.SetString(key, stringofids);

                if (HasDrivingLicence == true)
                {
                    ViewBag.Filter1 = "";
                }
                if (searchedFullname != null)
                {
                    ViewBag.Filters2 = searchedFullname;
                }
                if (searchedContact != null)
                {
                    ViewBag.Filter3 = searchedContact;
                }
                if (gender != null)
                {
                    ViewBag.Filter5 = gender;
                }
                if (searchedAddress != null)
                {
                    ViewBag.Filter6 = searchedAddress;
                }
                if (searchedworkplace != null)
                {
                    ViewBag.Filter7 = searchedworkplace;
                }
                if (searchedRemarks != null)
                {
                    ViewBag.Filter8 = searchedRemarks;
                }
                if (searchedOccupation != null)
                {
                    ViewBag.Filter9 = searchedOccupation;
                }
                if (searchedHourCount != 0)
                {
                    ViewBag.Filter10 = searchedHourCount.ToString();
                }
                if (Active != false)
                {
                    ViewBag.Filter11 = "";
                }
                if (HasCar != false)
                {
                    ViewBag.Filter12 = "";
                }
                DateTime date = Convert.ToDateTime("01.01.0001 00:00:00");
                if (lowerdate != date)
                {
                    ViewBag.Filter13 = lowerdate.ToString();
                }
                if (upperdate != date)
                {
                    ViewBag.Filter14 = upperdate.ToString();
                }
                ViewBag.page             = UniversalFunctions.GetCurrentPage(page);
                ViewBag.searchedFullname = searchedFullname;
                ViewBag.active           = Active;
                ViewBag.ContactInfo      = searchedContact;
                ViewBag.SortOrder        = sortOrder;
                ViewBag.Address          = searchedAddress;
                ViewBag.Occupation       = searchedOccupation;
                ViewBag.Remarks          = searchedRemarks;
                ViewBag.HourCount        = searchedHourCount;
                ViewBag.Upperdate        = upperdate;
                ViewBag.Lowerdate        = lowerdate;
                ViewBag.Gender           = gender;
                ViewBag.hascar           = HasCar;
                ViewBag.DesiredWorkplace = searchedworkplace;
                ViewBag.hasDriverLicence = HasDrivingLicence;
                ViewBag.NameSortParm     = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
                ViewBag.DateSortParm     = sortOrder == "Date" ? "date_desc" : "Date";
                ViewBag.FullnameSort     = sortOrder == "Fullname" ? "Fullname_desc" : "Fullname";
                ViewBag.HourCountSort    = sortOrder == "Hourcount" ? "Hourcount_desc" : "Hourcount";
                ViewBag.Gendersort       = sortOrder == "Gender" ? "Gender_desc" : "Gender";
                ViewBag.Activesort       = sortOrder == "Active" ? "Active_desc" : "Active";
                ViewBag.nrofdocs         = nrofdocs;

                return(View(volunteers));
            }
            catch
            {
                return(RedirectToAction("Localserver", "Home"));
            }
        }