public async Task <IActionResult> VolunteerJobsDelete(VolunteerJobModel job)
        {
            VolunteerRepository repo = new VolunteerRepository(configModel.ConnectionString);
            var user = await userManager.GetUserAsync(User);

            VolunteerJobModel dbJob = null;

            // Verify the user is a staff member
            if (!User.IsInRole(UserHelpers.UserRoles.Staff.ToString()))
            {
                return(Utilities.ErrorJson("Not authorized"));
            }

            dbJob = repo.GetVolunteerJob(job.Id, DateTime.MinValue);

            // Get job from database to check it exists
            if (dbJob == null)
            {
                return(Utilities.ErrorJson("Invalid id"));
            }

            try
            {
                repo.DeleteVolunteerJob(job);
            }
            catch (Exception e)
            {
                return(Utilities.ErrorJson(e.Message));
            }

            return(Utilities.NoErrorJson());
        }
        public async Task <IActionResult> VolunteerJobsEdit(VolunteerJobModel job)
        {
            VolunteerRepository repo = new VolunteerRepository(configModel.ConnectionString);
            var user = await userManager.GetUserAsync(User);

            VolunteerJobModel dbJob = null;

            // Verify the user is a staff member
            if (!User.IsInRole(UserHelpers.UserRoles.Staff.ToString()))
            {
                return(Utilities.ErrorJson("Not authorized"));
            }

            dbJob = repo.GetVolunteerJob(job.Id, DateTime.MinValue);

            // Get job from database to check that it exists
            if (dbJob == null)
            {
                return(Utilities.ErrorJson("Invalid id"));
            }

            // Validate inputs
            if (String.IsNullOrEmpty(job.Name))
            {
                return(Utilities.ErrorJson("Name is required"));
            }
            if (job.Min < 0)
            {
                return(Utilities.ErrorJson("Minimum number of volunteers for ajob must be non-negative"));
            }
            if (job.Max <= 0)
            {
                return(Utilities.ErrorJson("Maximum number of volunteers for a job must be positive"));
            }
            if (job.Max < job.Min)
            {
                return(Utilities.ErrorJson("Maximum number of volunteers for a job cannot be less than the minimum number of volunteers"));
            }

            try
            {
                repo.UpdateVolunteerJob(job);
            }
            catch (Exception e)
            {
                return(Utilities.ErrorJson(e.Message));
            }

            return(Utilities.NoErrorJson());
        }
        public async Task <IActionResult> VolunteerJob(int id)
        {
            var user = await userManager.GetUserAsync(User);

            VolunteerRepository repo = new VolunteerRepository(configModel.ConnectionString);
            VolunteerJobModel   job  = null;

            // Verify the user is a staff member
            if (!User.IsInRole(UserHelpers.UserRoles.Staff.ToString()))
            {
                return(Utilities.ErrorJson("Not authorized"));
            }

            if (id == 0)
            {
                return(Utilities.ErrorJson("Invalid id"));
            }

            try
            {
                job = repo.GetVolunteerJob(id, DateTime.MinValue);

                if (job == null)
                {
                    return(Utilities.ErrorJson("Invalid id"));
                }

                return(new JsonResult(new
                {
                    Error = "",
                    Job = job
                }));
            }
            catch (Exception e)
            {
                return(Utilities.ErrorJson(e.Message));
            }
        }