Пример #1
0
        public void LeaveGroup(sp_Vol_GroupVol_DM GroupVol)
        {
            using (VolTeerEntities context = new VolTeerEntities())
            {
                try
                {
                    var GroupToRemove = (from n in context.tblGroupVols where n.VolID == GroupVol.VolID && n.GroupID == GroupVol.GroupID select n).FirstOrDefault();
                    context.tblGroupVols.Remove(GroupToRemove);
                    context.SaveChanges();

                }
                catch (Exception ex)
                {
                    throw (ex);
                }

            }
        }
Пример #2
0
        public void TestGroupVolCreate()
        {
            var group_bll = new sp_Group_BLL();
            var vol_bll = new sp_Volunteer_BLL();
            var groupVol_bll = new sp_GroupVol_BLL();
            var groupVol_dm = new sp_Vol_GroupVol_DM();
            var allGroups = group_bll.ListGroups();
            var allVols = vol_bll.ListVolunteers();
            Assert.IsTrue(allGroups.Count > 0, "ListGroups() is broken or no data in DB");
            Assert.IsTrue(allVols.Count > 0, "ListVolunteers() is broken or no data in DB");
            groupVol_dm.GroupID = allGroups[0].GroupID;
            groupVol_dm.VolID = allVols[0].VolID;
            groupVol_dm.Admin = true;
            groupVol_dm.PrimaryVolID = true;
            groupVol_bll.InsertGroupContext(ref groupVol_dm);

            var groupVol_dm_selected = groupVol_bll.ListGroupVols(groupVol_dm);
            Assert.AreEqual(1, groupVol_dm_selected.Count);
            Assert.IsTrue(Equals(groupVol_dm, groupVol_dm_selected[0]));
        }
Пример #3
0
        protected void rBTNInvite_Click(object sender, EventArgs e)
        {
            foreach (GridDataItem item in rGridGroupVol.Items)
            {
                if (item.Selected == true)
                {
                    int GroupID = Convert.ToInt32(item.GetDataKeyValue("GroupID").ToString());
                    RadButton btnInvite = (RadButton)sender;
                    Guid VolID = new Guid(btnInvite.CommandArgument.ToString());

                    sp_Vol_GroupVol_DM GroupVol = new sp_Vol_GroupVol_DM();
                    GroupVol.VolID = VolID;
                    GroupVol.GroupID = GroupID;

                    GroupVolBLL.InsertGroupContext(ref GroupVol);

                }

            }
            rGridVolInvite.Rebind();
        }
Пример #4
0
        public sp_Vol_GroupVol_DM InsertGroupContext(ref sp_Vol_GroupVol_DM _cGroup)
        {
            using (VolTeerEntities context = new VolTeerEntities())
            {
                var cGroup = new tblGroupVol
                {
                    GroupID = _cGroup.GroupID,
                    VolID = _cGroup.VolID,
                    PrimaryVolID = _cGroup.PrimaryVolID,
                    Admin = _cGroup.Admin

                };
                context.tblGroupVols.Add(cGroup);
                context.SaveChanges();

                // pass VolID back to BLL
                _cGroup.GroupID = cGroup.GroupID;

                return _cGroup;
            }
        }
Пример #5
0
        protected void rGridGroupVol_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            try
            {
                sp_Vol_GroupVol_DM GroupVol = new sp_Vol_GroupVol_DM();

                GroupVol.VolID = (Guid)currentUser.ProviderUserKey;
                rGridGroupVol.DataSource = GroupVolBLL.ListGroupVols(GroupVol);
            }
            catch (Exception ex)
            {
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                string errMethod = sf.GetMethod().Name.ToString();  // Get the current method name
                string errMsg = "600";                              // Gotta pass something, we're retro-fitting an existing method
                Session["LastException"] = ex;                      // Throw the exception in the session variable, will be used in error page
                string url = string.Format(ConfigurationManager.AppSettings["ErrorPageURL"], errMethod, errMsg); //Set the URL
                Response.Redirect(url);                             // Go to the error page.

            }
        }
Пример #6
0
        public List<sp_Vol_GroupVol_DM> ListGroupVols(sp_Vol_GroupVol_DM GroupVol)
        {
            List<sp_Vol_GroupVol_DM> list = new List<sp_Vol_GroupVol_DM>();
            try
            {
                using (VolTeerEntities context = new VolTeerEntities())
                {
                    list = (from result in context.sp_GroupVol_Select(GroupVol.GroupID, GroupVol.VolID)
                            select new sp_Vol_GroupVol_DM
                            {
                                GroupName = result.GroupName,
                                ParticipationLevelID = result.ParticipationLevelID,
                                Admin = result.Admin,
                                GroupActive = result.GroupActive,
                                GroupID = result.GroupID,
                                PrimaryVolID = result.PrimaryVolID,
                                VolActive = result.VolActive,
                                VolFirstName = result.VolFirstName,
                                VolMiddleName = result.VolMiddleName,
                                VolLastName = result.VolLastName,
                                VolID = result.VolID
                            }).ToList();
                } // Guaranteed to close the Connection
            }
            catch (Exception ex)
            {
                throw (ex);
            }

            return list;
        }
Пример #7
0
        public void MakePrimaryVolID(sp_Vol_GroupVol_DM _cGroup)
        {
            using (VolTeerEntities context = new VolTeerEntities())
            {
                var cGroup = context.tblGroupVols.Find(_cGroup.GroupID);
                var cVol = context.tblGroupVols.Find(_cGroup.VolID);

                if (cGroup.GroupID == _cGroup.GroupID && cGroup.VolID == _cGroup.VolID)
                {
                    cGroup.GroupID = _cGroup.GroupID;
                    cGroup.VolID = _cGroup.VolID;
                    cGroup.PrimaryVolID = false;
                    context.SaveChanges();
                }

                else if (cGroup.GroupID == _cGroup.GroupID && cGroup.VolID != _cGroup.VolID)
                {
                    cGroup.GroupID = _cGroup.GroupID;
                    cGroup.VolID = _cGroup.VolID;
                    cGroup.PrimaryVolID = true;
                    context.SaveChanges();
                }
            }
        }
Пример #8
0
 //TODO: Create a MakePrimary method passing in VolID
 public void MakePrimaryVolID(sp_Vol_GroupVol_DM _cGroup)
 {
     DAL.MakeAdminVolID(_cGroup);
 }
Пример #9
0
 public List<sp_Vol_GroupVol_DM> ListGroupVols(sp_Vol_GroupVol_DM GroupVol)
 {
     return DAL.ListGroupVols(GroupVol);
 }
Пример #10
0
 public void LeaveGroup(sp_Vol_GroupVol_DM GroupVol)
 {
     DAL.LeaveGroup(GroupVol);
 }
Пример #11
0
 //TODO: Create an insert method passing in domain model
 public sp_Vol_GroupVol_DM InsertGroupContext(ref sp_Vol_GroupVol_DM _cGroup)
 {
     return DAL.InsertGroupContext(ref _cGroup);
 }
Пример #12
0
 //TODO: Create a delete all method passing in VolID
 public void DeleteGroupContext(sp_Vol_GroupVol_DM _cVolID)
 {
     DAL.DeleteGroupContext(_cVolID);
 }
Пример #13
0
 bool Equals(sp_Vol_GroupVol_DM dm1, sp_Vol_GroupVol_DM dm2)
 {
     return (dm1.GroupID == dm2.GroupID &&
             dm1.VolID == dm2.VolID &&
             dm1.PrimaryVolID == dm2.PrimaryVolID &&
             dm1.Admin == dm2.Admin
             );
 }
Пример #14
0
 private static List<sp_Vol_GroupVol_DM> DMsFrom(DataTable dataTable)
 {
     var DMs = new List<sp_Vol_GroupVol_DM>();
     for (int i = 0; i < dataTable.Rows.Count; i++)
     {
         var returnGroupVol = new sp_Vol_GroupVol_DM();
         returnGroupVol.GroupID = Convert.ToInt32(dataTable.Rows[i]["GroupID"]);
         returnGroupVol.VolID = new Guid((string)dataTable.Rows[i]["VolID"]);
         returnGroupVol.Admin = Convert.ToBoolean(dataTable.Rows[i]["Admin"]);
         returnGroupVol.PrimaryVolID = Convert.ToBoolean(dataTable.Rows[i]["PrimaryVolID"]);
         DMs.Add(returnGroupVol);
     }
     return DMs;
 }