Exemple #1
0
        public async void PopulateActivityList(ListVM instance)
        {
            FileHelper.FileReader fr      = new FileHelper.FileReader();
            var             xmlDoc        = XElement.Load(fr.ReadFile());
            List <XElement> activityNodes = xmlDoc.Descendants().Where(x => x.Name.ToString().Equals("Activity")).ToList();

            for (var i = 0; i > activityNodes.Count; i++)
            {
                var activity = new ActivityVM();
                activity.Name                      = activityNodes[i].Descendants("Name").ToString();
                activity.Example_wav_path          = activityNodes[i].Descendants("Example_wav_path").ToString();
                activity.Pitch                     = Convert.ToInt32(activityNodes[i].Descendants("Pitch").ToString());
                activity.PitchEvaluated            = Convert.ToBoolean(activityNodes[i].Descendants("PitchEvaluated").ToString());
                activity.Intensity                 = Convert.ToInt32(activityNodes[i].Descendants("Intensity").ToString());
                activity.IntensityEvaluated        = Convert.ToBoolean(activityNodes[i].Descendants("IntensityEvaluated").ToString());
                activity.F0_exact                  = Convert.ToInt32(activityNodes[i].Descendants("F0_exact").ToString());
                activity.F0_exactEvaluated         = Convert.ToBoolean(activityNodes[i].Descendants("F0_exactEvaluated").ToString());
                activity.F0_stable                 = Convert.ToInt32(activityNodes[i].Descendants("F0_stable").ToString());
                activity.F0_stableEvaluated        = Convert.ToBoolean(activityNodes[i].Descendants("F0_stableEvaluated").ToString());
                activity.Intensite_stable          = Convert.ToInt32(activityNodes[i].Descendants("Intensite_stable").ToString());
                activity.Intensite_stableEvaluated = Convert.ToBoolean(activityNodes[i].Descendants("Intensite_stableEvaluated").ToString());
                activity.Courbe_f0_exacte          = Convert.ToInt32(activityNodes[i].Descendants("Courbe_f0_exacte").ToString());
                activity.Courbe_f0_exacteEvaluated = Convert.ToBoolean(activityNodes[i].Descendants("Courbe_f0_exacteEvaluated").ToString());
                activity.Duree_exacte              = Convert.ToInt32(activityNodes[i].Descendants("Duree_exacte").ToString());
                activity.Duree_exacteEvaluated     = Convert.ToBoolean(activityNodes[i].Descendants("Duree_exacteEvaluated").ToString());
                activity.Jitter                    = Convert.ToInt32(activityNodes[i].Descendants("Jitter").ToString());
                activity.JitterEvaluated           = Convert.ToBoolean(activityNodes[i].Descendants("JitterEvaluated").ToString());

                instance.Add(activity);
            }
        }
Exemple #2
0
        public ActivityVM GetActivityVM(Activity activity)
        {
            var activityVM = new ActivityVM()
            {
                Id = activity.ID, Author = activity.User.FirstName, CreatedDate = activity.CreatedDate.ToJSONFriendlyDateTime()
            };

            if (activity.ActivityDesc.ToUpper() == "CREATED")
            {
                activityVM.Activity   = activity.ActivityDesc;
                activityVM.ObjectTite = activity.NewState;
            }
            else if (activity.ActivityDesc.ToUpper() == "CHANGED STATUS")
            {
                activityVM.Activity   = "changed status of";
                activityVM.ObjectTite = activity.OldState;
                activityVM.NewState   = "to " + activity.NewState;
            }
            else if (activity.ActivityDesc.ToUpper() == "DUE DATE UPDATED")
            {
                activityVM.Activity   = "updated due date of";
                activityVM.ObjectTite = activity.OldState;
                activityVM.NewState   = "to " + activity.NewState;
            }
            activityVM.ObjectURL = String.Format("{0}Issues/{1}", SiteBaseURL, activity.ObjectID);
            return(activityVM);
        }
Exemple #3
0
            private void populateExerciceList(string path, ListVM activityList)
            {
                XDocument xml        = XDocument.Load(path + "\\config.xml");
                var       activities = xml.Descendants("Activity");

                foreach (XElement activity in activities)
                {
                    ActivityVM newSuiviVM = new ActivityVM
                    {
                        Name                      = activity.Descendants("Name").First().Value,
                        Example_wav_path          = path + "\\" + activity.Descendants("Exercice_wav_file_name").First().Value,
                        PitchMin                  = Convert.ToInt32(activity.Descendants("Pitch_min").First().Value),
                        PitchMax                  = Convert.ToInt32(activity.Descendants("Pitch_max").First().Value),
                        IntensityThreshold        = Convert.ToInt32(activity.Descendants("Intensity_threshold").First().Value),
                        F0_exactEvaluated         = Convert.ToBoolean(activity.Descendants("F0_exactEvaluated").First().Value),
                        F0_stableEvaluated        = Convert.ToBoolean(activity.Descendants("F0_stableEvaluated").First().Value),
                        Intensite_stableEvaluated = Convert.ToBoolean(activity.Descendants("Intensite_stableEvaluated").First().Value),
                        Courbe_f0_exacteEvaluated = Convert.ToBoolean(activity.Descendants("Courbe_f0_exacteEvaluated").First().Value),
                        Duree_exacteEvaluated     = Convert.ToBoolean(activity.Descendants("Duree_exacteEvaluated").First().Value),
                        JitterEvaluated           = Convert.ToBoolean(activity.Descendants("JitterEvaluated").First().Value)
                    };
                    ICollection <DataLineItem> points = activity.Descendants("point").Select(x => new DataLineItem {
                        Time = double.Parse(x.Descendants("time").First().Value), Intensity = double.Parse(x.Descendants("frequency").First().Value), Pitch = double.Parse(x.Descendants("pitch").First().Value)
                    }).ToList();
                    newSuiviVM.Exercice = points;

                    activityList.Add(newSuiviVM);
                }
            }
Exemple #4
0
        public IActionResult EditActivity([FromBody] ActivityVM activityVM)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessages()));
            }

            var activity = db.Activities.Find(activityVM);

            if (activity == null)
            {
                return(NotFound("Activity Not Found"));
            }

            activity.Title         = activity.Title;
            activity.StartDateTime = activityVM.StartDateTime;
            activity.EndDateTime   = activityVM.EndDateTime;
            activity.Description   = activityVM.Description;

            db.Activities.Update(activity);

            db.SaveChanges();

            return(Ok("Activity Updated"));
        }
Exemple #5
0
        // This updates an activity schedule in the database.
        public int UpdateActivitySchedule(ActivityVM oldSchedule, ActivityVM newSchedule)
        {
            int rows = 0;

            var conn = DBConnection.GetConnection();
            var cmd  = new SqlCommand("sp_update_activity_schedule", conn);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@ScheduleID", oldSchedule.ScheduleID);

            cmd.Parameters.AddWithValue("@OldActivityID", oldSchedule.ActivityID);
            cmd.Parameters.AddWithValue("@OldStart", oldSchedule.Start);
            cmd.Parameters.AddWithValue("@OldEnd", oldSchedule.End);

            cmd.Parameters.AddWithValue("@NewActivityID", newSchedule.ActivityID);
            cmd.Parameters.AddWithValue("@NewStart", newSchedule.Start);
            cmd.Parameters.AddWithValue("@NewEnd", newSchedule.End);

            try
            {
                conn.Open();
                rows = cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }

            return(rows);
        }
        public async Task <ActivityVM> GetActivityListAsync(int pageno, int pagesize, string sterm)
        {
            try
            {
                ActivityVM model    = new ActivityVM();
                var        parStart = new SqlParameter("@Start", (pageno - 1) * pagesize);
                var        parEnd   = new SqlParameter("@PageSize", pagesize);

                var parSearchTerm = new SqlParameter("@SearchTerm", DBNull.Value);
                if (!(sterm == null || sterm == ""))
                {
                    parSearchTerm.Value = sterm;
                }
                // setting stored procedure OUTPUT value
                // This return total number of rows, and avoid two database call for data and total number of rows
                var spOutput = new SqlParameter
                {
                    ParameterName = "@TotalCount",
                    SqlDbType     = System.Data.SqlDbType.BigInt,
                    Direction     = System.Data.ParameterDirection.Output
                };

                model.ActivityList = await objDB.Database.SqlQuery <ActivityView>("udspMstActivitiesList @Start, @PageSize,@SearchTerm, @TotalCount out",
                                                                                  parStart, parEnd, parSearchTerm, spOutput).ToListAsync();

                model.TotalRecords = int.Parse(spOutput.Value.ToString());
                return(model);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public ActivityExecuter(ActivityVM currentActivity, Action <bool> playingAction, Action <string> setFeedback)
 {
     this.Player = new WAVPlayerRecorder(new Action <bool>(x =>
     {
         playingAction(x);
         if (x)
         {
             this.setFeedback(Environment.CurrentDirectory + "\\" + RessourceService.PlayingGifPath);
         }
         else
         {
             this.setFeedback("");
         }
     }));
     this.CurrentActivity    = currentActivity;
     this.scripting          = new PraatScripting(currentActivity.Name);
     this.connector          = PraatConnector.GetConnector();
     this.analyser           = new SoundAnalyser();
     this.setFeedback        = setFeedback;
     this.exerciceFolderPath = Environment.GetEnvironmentVariable("LocalAppData") + "\\MyOrtho\\" + this.CurrentActivity.Name + "\\";
     if (!Directory.Exists(this.exerciceFolderPath))
     {
         Directory.CreateDirectory(this.exerciceFolderPath);
     }
     currentExercicePath = this.exerciceFolderPath + DateTime.Now.ToString("yyyyMMddHHmmss");
 }
Exemple #8
0
        // This inserts an activity into the database
        public int InsertActivity(ActivityVM activity)
        {
            int personID = 0;
            var conn     = DBConnection.GetConnection();
            var cmd      = new SqlCommand("sp_insert_activity", conn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@ActivityName", activity.ActivityName);
            cmd.Parameters.AddWithValue("@ActivityTypeID", activity.ActivityTypeID);
            cmd.Parameters.AddWithValue("@LocationName", activity.LocationName);
            cmd.Parameters.AddWithValue("@Address1", activity.Address1);
            string address2 = activity.Address2 == null ? "" : activity.Address2;

            cmd.Parameters.AddWithValue("@Address2", address2);
            cmd.Parameters.AddWithValue("@City", activity.City);
            cmd.Parameters.AddWithValue("@State", activity.State);
            cmd.Parameters.AddWithValue("@Zip", activity.Zip);
            cmd.Parameters.AddWithValue("@Description", activity.Description);
            try
            {
                conn.Open();
                personID = Convert.ToInt32(cmd.ExecuteScalar());
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }

            return(personID);
        }
Exemple #9
0
        public FlatResult(ActivityVM activity)
        {
            if (activity.Courbe_f0_exacteEvaluated)
            {
                return;
            }

            this.activity = activity;

            _F0ExacteImage        = this.ConvertToBitMap((int)(activity.F0_exact * 100d));
            _F0StableImage        = this.ConvertToBitMap((int)(activity.F0_stable * 100d));
            _IntensiteStableImage = this.ConvertToBitMap((int)(activity.Intensite_stable * 100d));
            _DureeExacteImage     = this.ConvertToBitMap(ScoreProvider.EvaluateTimeLength(activity.Duree_expected, activity.Duree_exacte));
            _JitterImage          = this.ConvertToBitMap(ScoreProvider.EvaluateJitter(activity.Jitter));

            Jitter = activity.Jitter.ToString();

            InitializeComponent();

            this.F0ExacteResult.Source        = F0ExacteImage;
            this.F0StableResult.Source        = F0StableImage;
            this.IntensiteStableResult.Source = IntensiteStableImage;
            this.DureeExacteResult.Source     = DureeExacteImage;
            this.JitterResult.Source          = JitterImage;
        }
        private List <ActivityVM> GetTeamActivityVMs(int teamId, int size)
        {
            List <ActivityVM> activityVMList = new List <ActivityVM>();

            try
            {
                var activityList = repo.GetTeamActivity(teamId).OrderByDescending(s => s.CreatedDate).Take(size).ToList();

                var activityVM   = new ActivityVM();
                var issueService = new IssueService(repo, UserID, TeamID);
                issueService.SiteBaseURL = SiteBaseURL;
                var commentService = new CommentService(repo, SiteBaseURL);

                foreach (var item in activityList)
                {
                    if (item.ObjectType == ActivityObjectType.Issue.ToString())
                    {
                        // issueManager.GetActivityVM()
                        activityVM = issueService.GetActivityVM(item);
                    }
                    else if (item.ObjectType == ActivityObjectType.IssueComment.ToString())
                    {
                        activityVM = commentService.GetActivityVM(item);
                    }
                    activityVMList.Add(activityVM);
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
            return(activityVMList);
        }
Exemple #11
0
        public async Task <IActionResult> Index()
        {
            try
            {
                // GET SESSIONS
                SessionController sessionController = new SessionController();
                SessionBO         session           = sessionController.GetSession(HttpContext.Session);

                ApiRequest apiRequest = new ApiRequest();
                ResponseBO _res       = await apiRequest.GetAsync("User/Profile", session.SessionCookies);

                UserResponseBO apiResponse = JsonConvert.DeserializeObject <UserResponseBO>(_res.ResponseResult);

                TblUserInfo userInfo = apiResponse.UserInfo;
                TblUserAuth userAuth = apiResponse.UserAuth;

                if (apiResponse.HttpStatusCode == "200")
                {
                    ActivityVM activityVM = new ActivityVM();
                    activityVM.Fullname = String.Format("{0} {1}", userInfo.FirstName, userInfo.LastName);
                    activityVM.Username = userAuth.UserName;

                    return(View(activityVM));
                }
                else
                {
                    return(RedirectToAction("Login", "Home"));
                }
            }
            catch (System.Exception e)
            {
                return(RedirectToAction("Login", "Home"));
            }
        }
Exemple #12
0
        public async Task <int> Post(ActivityVM activity)
        {
            using (var sql = new SqlConnection(connectionString.Value))
            {
                sp = "SP_AddActivity";
                parameters.Add("uId", activity.UserId);
                parameters.Add("Name", activity.Name);
                parameters.Add("Create", DateTime.Now);
                var result = await sql.ExecuteAsync(sp, parameters, commandType : spType);

                return(result);
            }
        }
Exemple #13
0
        // When the selection in the dgUserActivityList data grid is changed this event handler is fired off. This method then assigns the
        // selected item to the _activity attribute and uses it to populate the text fields.
        private void DgUserActivityList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            _activity = (ActivityVM)dgUserActivityList.SelectedItem;
            lbGroupsParticipating.ItemsSource = _groupManager.RetrieveGroupsByActivityID(_activity.ActivityID);

            fillTextBoxes();
            showEditButton();
            disableFields();

            btnSave.Visibility = Visibility.Hidden;
            //btnCancel.Visibility = Visibility.Visible;
            //btnSignUp.Visibility = Visibility.Hidden;
        }
Exemple #14
0
        public static ActivityVM GetById(int id, BPARepo bpaRepo)
        {
            var activity = bpaRepo.Activities.GetById(id);
            var model    = new ActivityVM()
            {
                Id        = activity.Id,
                Name      = activity.Name,
                ManagerId = activity.ManagerId,
                Objective = activity.Objective,
            };

            return(model);
        }
Exemple #15
0
        public async Task <int> Put(int id, ActivityVM activity)
        {
            using (var sql = new SqlConnection(connectionString.Value))
            {
                sp = "SP_EditActivity";
                parameters.Add("Name", activity.Name);
                parameters.Add("Update", DateTime.Now);
                parameters.Add("Id", id);
                var result = await sql.ExecuteAsync(sp, parameters, commandType : spType);

                return(result);
            }
        }
Exemple #16
0
        // This selects a list of Activity view models from the database They are selected based upon and personID,
        // scheduleType, and if they are active.
        public List <ActivityVM> SelectUserSchedulesByUserIDAndType(int personID, string scheduleType, bool active)
        {
            List <ActivityVM> activities = new List <ActivityVM>();

            var conn = DBConnection.GetConnection();
            var cmd  = new SqlCommand("sp_select_all_user_schedules_by_user_id_and_type", conn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@PersonID", personID);
            cmd.Parameters.AddWithValue("@Type", scheduleType);
            cmd.Parameters.AddWithValue("@Active", active);
            try
            {
                conn.Open();
                var reader = cmd.ExecuteReader();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        var activity = new ActivityVM();

                        activity.ActivityID     = reader.GetInt32(0);
                        activity.ActivityName   = reader.GetString(1);
                        activity.ActivityTypeID = reader.GetString(2);
                        activity.Type           = reader.GetString(3);
                        activity.LocationName   = reader.GetString(4);
                        activity.Address1       = reader.GetString(5);
                        activity.Address2       = reader.GetString(6);
                        activity.City           = reader.GetString(7);
                        activity.State          = reader.GetString(8);
                        activity.Zip            = reader.GetString(9);
                        activity.Description    = reader.GetString(10);
                        activity.ScheduleID     = reader.GetInt32(11);
                        activity.PersonID       = reader.GetInt32(12);
                        activity.Start          = reader.GetDateTime(13);
                        activity.End            = reader.GetDateTime(14);

                        activities.Add(activity);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }
            return(activities);
        }
Exemple #17
0
        // This adds an activity from the presentation to the data access layer.
        public int AddActivity(ActivityVM activity)
        {
            int identity;

            try
            {
                identity = _activityAccessor.InsertActivity(activity);
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Activity not Added!", ex);
            }
            return(identity);
        }
Exemple #18
0
        // This calls the accessor method that updates an activity in the database
        public bool EditActivitySchedule(ActivityVM oldSchedule, ActivityVM newSchedule)
        {
            bool result = false;

            try
            {
                result = 1 == _scheduleAccessor.UpdateActivitySchedule(oldSchedule, newSchedule);
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Activity schedule not updated", ex);
            }
            return(result);
        }
Exemple #19
0
        public ActionResult UpdateActivity(ActivityVM model)
        {
            try
            {
                ActivityServices.Update(model, BPARepo);

                return(RedirectToAction("Activity"));
            }
            catch (Exception ex)
            {
                SetViewError(ex);
                return(View(model));
            }
        }
Exemple #20
0
        // This event handler is fired when the sign up button is clicked. It signs the user up for an activity which indicates that they intend
        // to attend it.
        private void BtnSignUp_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (dgActivityList.SelectedItems.Count == 0)
                {
                    MessageBox.Show("You must make a selection\nfrom List of Upcoming Activities.");
                    return;
                }
                if (_addMode)
                {
                    return;
                }
                ActivityVM activity   = (ActivityVM)dgActivityList.SelectedItem;
                var        activities = _activityManager.RetrieveActivitiesByPersonID(_user.PersonID);

                foreach (var a in activities)
                {
                    if (a.ActivityID == activity.ActivityID)
                    {
                        MessageBox.Show("You are already signed up for that activity.");
                        return;
                    }
                }
                if (MessageBox.Show("Are you sure?", "Sign up Activity", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No)
                {
                    //chkActive.IsChecked = !(bool)chkActive.IsChecked;
                    return;
                }
                try
                {
                    activity = (ActivityVM)dgActivityList.SelectedItem;
                    if (_activityManager.AddPersonActivity(_user.PersonID, activity.ActivityID))
                    {
                        populatePeopleAttendingList();
                        populateUserActivityList();
                    }
                    //populateUserActivityList();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message + "\n\n" + ex.InnerException.Message);
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show("BAD");
            }
        }
Exemple #21
0
        public CurveResult(ActivityVM activity)
        {
            if (!activity.Courbe_f0_exacteEvaluated)
            {
                return;
            }

            this.activity = activity;

            _CourbeF0ExacteImage = this.ConvertToBitMap((int)(activity.Courbe_f0_exacte * 100d));

            InitializeComponent();

            this.CourbeF0ExacteResult.Source = CourbeF0ExacteImage;
        }
Exemple #22
0
 public ActionResult EditActivity(ActivityVM newActivity)
 {
     try
     {
         var oldActivity = _activityManager.RetrieveActivityByID(newActivity.ActivityID);
         _activityManager.EditActivity(oldActivity, newActivity);
         _scheduleManager.EditActivitySchedule(oldActivity, newActivity);
         return(RedirectToAction("ActivityList", new { message = "Activity Updated." }));
     }
     catch (Exception)
     {
         ViewBag.ActivityTypeList = _activityManager.RetrieveAllActivityTypes();
         return(View());
     }
 }
Exemple #23
0
        // This call the accessor method that updates an activity in the database.
        public bool EditActivity(ActivityVM oldActivity, ActivityVM newActivity)
        {
            {
                bool result = false;
                try
                {
                    result = 1 == _activityAccessor.UpdateActivity(oldActivity, newActivity);
                }
                catch (Exception ex)
                {
                    throw new ApplicationException("Update failed", ex);
                }

                return(result);
            }
        }
Exemple #24
0
        public ActionResult CreateActivity(ActivityVM activity)
        {
            try
            {
                int activityID = _activityManager.AddActivity(activity);

                _activityManager.AddActivitySchedule(activityID, activity.Start, activity.End);

                return(RedirectToAction("ActivityList", new { message = "Activity Created." }));
            }
            catch (Exception)
            {
                ViewBag.ActivityTypeList = _activityManager.RetrieveAllActivityTypes();
                return(View());
            }
        }
 // POST: ToDoLists/UpdateStatus/5
 public ActionResult Complete(int id, ActivityVM activityVM)
 {
     try
     {
         var myContent   = JsonConvert.SerializeObject(activityVM);
         var buffer      = System.Text.Encoding.UTF8.GetBytes(myContent);
         var ByteContent = new ByteArrayContent(buffer);
         ByteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
         var update = httpClient.PutAsync("Activities/Complete/" + id, ByteContent).Result;
         return(Json(new { data = update, update.StatusCode }));
     }
     catch
     {
         return(View());
     }
 }
 // POST: ToDoLists/Create
 public ActionResult Create(ActivityVM activityVM)
 {
     try
     {
         var myContent   = JsonConvert.SerializeObject(activityVM);
         var buffer      = System.Text.Encoding.UTF8.GetBytes(myContent);
         var byteContent = new ByteArrayContent(buffer);
         byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
         var affectedRow = httpClient.PostAsync("Activities", byteContent).Result;
         return(Json(new { data = affectedRow, affectedRow.StatusCode }));
     }
     catch
     {
         return(View());
     }
 }
        // This event handler is fired when the "Sign-up for Activity" button is pushed.
        // This will add a schedule for the user to volunteer for.
        private void BtnSignupActivity_Click(object sender, RoutedEventArgs e)
        {
            // check to see if the user has a list item selected and gives a prompt if
            // they did not
            if (dgVolunteerActivities.SelectedItem == null)
            {
                MessageBox.Show("You must make a volunteering selection.");
                return;
            }
            else
            {
                // Checks to make sure the user is not already signed up for this activity
                List <ActivityVM> activities = _activityManager.RetrieveActivitiesByScheduleType(_user.PersonID, "Volunteer");
                foreach (ActivityVM a in activities)
                {
                    if (a.ActivityID == ((ActivityVM)dgVolunteerActivities.SelectedItem).ActivityID)
                    {
                        MessageBox.Show("You are already signed up to volunteer for this activity");
                        return;
                    }
                }

                // This asks the user if they are sure they want to volunteer, and if they choose
                // will be signed up
                if (MessageBox.Show("Are you sure?", "Sign-up to Volunteer", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
                {
                    ActivityVM activity = (ActivityVM)dgVolunteerActivities.SelectedItem;
                    Schedule   schedule = new Schedule()
                    {
                        PersonID         = _user.PersonID,
                        ActivityID       = activity.ActivityID,
                        Type             = "Volunteer",
                        ActivitySchedule = false,
                        Start            = activity.Start,
                        End = activity.End
                    };
                    if (_scheduleManager.AddSchedule(schedule))
                    {
                        MessageBox.Show("Volunteer Schedule added");
                        populateUserVolunteerActivities();
                        checkVolunteerStatus();
                    }
                }
            }
        }
Exemple #28
0
        /// <summary>
        /// Selects an activity by id and active
        /// </summary>
        /// <param name="activityID"></param>
        /// <param name="active"></param>
        /// <returns></returns>
        public ActivityVM SelectActivityByActivityID(int activityID)
        {
            ActivityVM activity = new ActivityVM();

            var conn = DBConnection.GetConnection();
            var cmd  = new SqlCommand("sp_select_activity_by_id", conn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@ActivityID", activityID);

            try
            {
                conn.Open();
                var reader = cmd.ExecuteReader();
                if (reader.Read())
                {
                    activity.ActivityID     = reader.GetInt32(0);
                    activity.ActivityName   = reader.GetString(1);
                    activity.ActivityTypeID = reader.GetString(2);
                    //activity.Type = reader.GetString(3);
                    activity.LocationName = reader.GetString(4);
                    activity.Address1     = reader.GetString(5);
                    activity.Address2     = reader.GetString(6);
                    activity.City         = reader.GetString(7);
                    activity.State        = reader.GetString(8);
                    activity.Zip          = reader.GetString(9);
                    activity.Description  = reader.GetString(10);
                    activity.ScheduleID   = reader.GetInt32(11);
                    //activity.PersonID = reader.GetInt32(12);

                    activity.Start          = reader.GetDateTime(13);
                    activity.End            = reader.GetDateTime(14);
                    activity.ActivityActive = reader.GetBoolean(15);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }
            return(activity);
        }
Exemple #29
0
        // Thios updates an activity.
        public int UpdateActivity(ActivityVM oldActivity, ActivityVM newActivity)
        {
            int rows = 0;

            var conn = DBConnection.GetConnection();
            var cmd  = new SqlCommand("sp_update_activity", conn);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@ActivityID", oldActivity.ActivityID);

            cmd.Parameters.AddWithValue("@OldActivityName", oldActivity.ActivityName);
            cmd.Parameters.AddWithValue("@OldActivityTypeID", oldActivity.ActivityTypeID);
            cmd.Parameters.AddWithValue("@OldLocationName", oldActivity.LocationName);
            cmd.Parameters.AddWithValue("@OldAddress1", oldActivity.Address1);
            cmd.Parameters.AddWithValue("@OldAddress2", oldActivity.Address2);
            cmd.Parameters.AddWithValue("@OldCity", oldActivity.City);
            cmd.Parameters.AddWithValue("@OldState", oldActivity.State);
            cmd.Parameters.AddWithValue("@OldZip", oldActivity.Zip);
            cmd.Parameters.AddWithValue("@OldDescription", oldActivity.Description);

            cmd.Parameters.AddWithValue("@NewActivityName", newActivity.ActivityName);
            cmd.Parameters.AddWithValue("@NewActivityTypeID", newActivity.ActivityTypeID);
            cmd.Parameters.AddWithValue("@NewLocationName", newActivity.LocationName);
            cmd.Parameters.AddWithValue("@NewAddress1", newActivity.Address1);
            string address2 = newActivity.Address2 == null ? "" : newActivity.Address2;

            cmd.Parameters.AddWithValue("@NewAddress2", address2);
            cmd.Parameters.AddWithValue("@NewCity", newActivity.City);
            cmd.Parameters.AddWithValue("@NewState", newActivity.State);
            cmd.Parameters.AddWithValue("@NewZip", newActivity.Zip);
            cmd.Parameters.AddWithValue("@NewDescription", newActivity.Description);

            try
            {
                conn.Open();
                rows = cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }

            return(rows);
        }
Exemple #30
0
        public static List <ActivityVM> GetAll(BPARepo bpaRepo)
        {
            var activities = bpaRepo.Activities.GetAll().ToList();
            var model      = new List <ActivityVM>();

            foreach (var activity in activities)
            {
                var activityVM = new ActivityVM()
                {
                    Id        = activity.Id,
                    Name      = activity.Name,
                    ManagerId = activity.ManagerId,
                    Objective = activity.Objective,
                };
                model.Add(activityVM);
            }

            return(model);
        }