Esempio n. 1
0
        public ActionResult AddActivity(int id)
        {
            List <string> errs = new List <string>();

            ActivityByMemberModels memberActivities = new ActivityByMemberModels();

            using (LRCEntities context = new LRCEntities())
            {
                var tb_MemberMaster = context.tb_MemberMaster.ToList();
                ViewBag.ActivityStatus      = context.tb_ActivityStatus.ToList();
                ViewBag.ActivityStatusAfter = new List <SelectListItem>
                {
                    new SelectListItem {
                        Value = "0", Text = "Participated", Selected = false
                    },
                    new SelectListItem {
                        Value = "1", Text = "Not Participated", Selected = false
                    }
                };

                SelectList     Activities  = new SelectList(db.tb_Activity.OrderBy(s => s.ActivityName), "ActivityID", "ActivityName");
                SelectListItem selListItem = new SelectListItem()
                {
                    Value = "0", Text = " Select Activity "
                };
                ViewBag.ActivityID = CommonFunctions.AddFirstItem(Activities, selListItem);
            }
            memberActivities.MemberID = id;
            ViewBag.MemberActivities  = db.tb_MemberActivity.Where(a => a.MemberID == id).OrderBy(s => s.ActivityID).ToList();
            tb_MemberMaster fm = db.tb_MemberMaster.Find(id);

            ViewBag.MemberName = fm.FirstName + " " + fm.LastName;
            return(View(memberActivities));
        }
Esempio n. 2
0
        public ActionResult AddActivityByMember()
        {
            //https://www.youtube.com/watch?v=z3ViZ6XA884 Asp.Net MVC - Searchable and Multi-select Drop DownList Using Chosen Plugin
            //Chosen Plugin https://harvesthq.github.io/chosen/
            ActivityByMemberModels memberActivities = new ActivityByMemberModels();

            using (LRCEntities context = new LRCEntities())
            {
                var tb_MemberMaster           = context.tb_MemberMaster.ToList();
                List <SelectListItem> members = new List <SelectListItem>();
                foreach (var member in tb_MemberMaster)
                {
                    members.Add(new SelectListItem()
                    {
                        Text  = member.FirstName + " " + member.LastName,
                        Value = member.MemberID.ToString()
                    });
                    memberActivities.MemberCollection = members.OrderBy(s => s.Text).ToList();
                }

                ViewBag.ActivityStatus      = context.tb_ActivityStatus.ToList();
                ViewBag.ActivityStatusAfter = new List <SelectListItem>
                {
                    new SelectListItem {
                        Value = "0", Text = "Participated", Selected = false
                    },
                    new SelectListItem {
                        Value = "1", Text = "Not Participated", Selected = false
                    }
                };

                SelectList     Activities  = new SelectList(db.tb_Activity.OrderBy(s => s.ActivityName), "ActivityID", "ActivityName");
                SelectListItem selListItem = new SelectListItem()
                {
                    Value = "0", Text = " Select Activity "
                };
                ViewBag.ActivityID = CommonFunctions.AddFirstItem(Activities, selListItem);
            }

            return(View(memberActivities));
        }
Esempio n. 3
0
        public ActionResult AddPersonAssessmentActivity(int?id, int CollegeID)
        {
            //ViewBag.CollegeID = CollegeID;
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var tb_Assessment = db.tb_Assessment.Include(t => t.tb_MemberMaster);

            tb_Assessment = tb_Assessment.Where(f => f.tb_MemberMaster.MemberID == id);
            tb_Assessment Assessment = new tb_Assessment();
            var           uName      = HttpContext.GetOwinContext().Authentication.User.Identity.GetUserName();

            if (tb_Assessment.Count() == 0) //1st Assessment
            {
                Assessment.AddedBy          = uName;
                Assessment.AddedDateTime    = DateTime.Now;
                Assessment.AssessedBy       = uName;
                Assessment.AssessmentDate   = DateTime.Now;
                Assessment.AssessmentDesc   = String.Empty;
                Assessment.AssessmentNameID = 7; // Add Fee Payer Assess
                Assessment.MemberID         = id ?? default(int);
                Assessment.ModifiedBy       = uName;
                Assessment.ModifiedDateTime = DateTime.Now;
                Assessment.ValueID          = 1;
            }
            else
            {
                Assessment = tb_Assessment.FirstOrDefault();
            }

            SelectList FeePayerAssess = new SelectList(db.tb_AssessmentName.OrderBy(s => s.AssessmentName), "AssessmentNameID", "AssessmentName", Assessment.AssessmentNameID /* selected value */);

            ViewBag.AssessmentNameID = FeePayerAssess;

            SelectList AssessmentValue = new SelectList(db.tb_AssessmentValue, "ValueID", "ValueName", Assessment.ValueID /* selected value */);

            ViewBag.ValueID = AssessmentValue;

            SelectList AspNetUsers = new SelectList(db.AspNetUsers.OrderBy(s => s.LastFirstName), "Id", "LastFirstName");

            ViewBag.AssessedBy = AspNetUsers;

            List <tb_ActivityStatus> ActivityStatuses = new List <tb_ActivityStatus>();

            ViewBag.ActivityStatus      = db.tb_ActivityStatus.ToList();
            ViewBag.ActivityStatusAfter = new List <SelectListItem>
            {
                new SelectListItem {
                    Value = "0", Text = "Participated", Selected = false
                },
                new SelectListItem {
                    Value = "1", Text = "Not Participated", Selected = false
                }
            };

            SelectList     Activities  = new SelectList(db.tb_Activity.OrderBy(s => s.ActivityName), "ActivityID", "ActivityName");
            SelectListItem selListItem = new SelectListItem()
            {
                Value = "0", Text = " Select Activity "
            };

            ViewBag.ActivityID = CommonFunctions.AddFirstItem(Activities, selListItem);

            List <tb_MemberActivity> MemberActivities = new List <tb_MemberActivity>();

            MemberActivities = db.tb_MemberActivity.Where(a => a.MemberID == id).OrderBy(s => s.ActivityID).ToList();

            tb_MemberMaster fm = db.tb_MemberMaster.Find(id);

            ViewBag.MemberName = fm.FirstName + " " + fm.LastName;

            var model = new AssessActivityModels()
            {
                _Assessment        = Assessment,
                _Activity          = db.tb_Activity.FirstOrDefault(),
                _ActivityStatus    = ActivityStatuses,
                _MemberActivity    = MemberActivities,
                _MemberAssessments = tb_Assessment.ToList(),
                _CollegeID         = CollegeID
            };

            return(View(model));
        }
Esempio n. 4
0
        public ActionResult AddPersonAssessmentActivity(int id, string submit, int AssessmentNameID, string AssessedBy, int ActivityID,
                                                        int ActivityStatusID, int ValueID, AssessActivityModels model, FormCollection formCollection)
        {
            //if (id == null)
            //{
            //    return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            //}
            Error error = new Error();

            error.errCode = ErrorDetail.Success;
            List <string> errs   = new List <string>();
            string        userId = HttpContext.GetOwinContext().Authentication.User.Identity.GetUserId();

            //string uLastFirstName = db.AspNetUsers.Where(s => s.Email == uName).FirstOrDefault().LastFirstName;

            //ViewBag.CollegeID = CollegeID;

            #region Prepare Model (ASSESSMENT Part)

            SelectList FeePayerAssess = new SelectList(db.tb_AssessmentName.OrderBy(s => s.AssessmentName), "AssessmentNameID", "AssessmentName", AssessmentNameID /* selected value */);
            ViewBag.AssessmentNameID = FeePayerAssess;

            SelectList AssessmentValue = new SelectList(db.tb_AssessmentValue, "ValueID", "ValueName", ValueID /* selected value */);
            ViewBag.ValueID = AssessmentValue;

            SelectList AspNetUsers = new SelectList(db.AspNetUsers.OrderBy(s => s.LastFirstName), "Id", "LastFirstName");
            ViewBag.AssessedBy = AspNetUsers;

            model._Assessment.ValueID          = ValueID;
            model._Assessment.AssessmentNameID = AssessmentNameID;
            model._Assessment.AssessedBy       = AssessedBy;
            model._Assessment.AddedDateTime    = DateTime.Now;
            model._MemberAssessments           = db.tb_Assessment.Where(f => f.tb_MemberMaster.MemberID == id).ToList();

            #endregion

            #region Prepare Model (ACTIVITY Part)

            model._ActivityStatus = db.tb_ActivityStatus.ToList();

            ViewBag.ActivityStatusAfter = new List <SelectListItem>
            {
                new SelectListItem {
                    Value = "0", Text = "Participated", Selected = false
                },
                new SelectListItem {
                    Value = "1", Text = "Not Participated", Selected = false
                }
            };

            SelectList     Activities  = new SelectList(db.tb_Activity.OrderBy(s => s.ActivityName), "ActivityID", "ActivityName");
            SelectListItem selListItem = new SelectListItem()
            {
                Value = "0", Text = " Select Activity "
            };
            ViewBag.ActivityID = CommonFunctions.AddFirstItem(Activities, selListItem);

            model._MemberActivity = db.tb_MemberActivity.Where(s => s.MemberID == id).ToList();

            tb_MemberMaster fm = db.tb_MemberMaster.Find(id);
            ViewBag.MemberName = fm.FirstName + " " + fm.LastName;

            #endregion

            if (submit == "Submit") //Adding Assessment
            {
                if (ModelState.IsValid)
                {
                    try
                    {
                        model._Assessment.AddedBy = userId;
                        db.tb_Assessment.Add(model._Assessment);
                        db.SaveChanges();
                    }
                    catch (DbEntityValidationException ex)
                    {
                        error.errCode = ErrorDetail.DataImportError;
                        error.errMsg  = ErrorDetail.GetMsg(error.errCode);
                        foreach (DbEntityValidationResult validationError in ex.EntityValidationErrors)
                        {
                            error.errMsg += ". Object: " + validationError.Entry.Entity.ToString();
                            foreach (DbValidationError err in validationError.ValidationErrors)
                            {
                                error.errMsg += ". " + err.ErrorMessage;
                            }
                        }
                        errs.Add("Error #" + error.errCode.ToString() + "!" + error.errMsg);
                        ViewData["AssessmentErrorList"] = errs;
                        return(View(model));
                    }

                    model._MemberAssessments = db.tb_Assessment.Where(f => f.tb_MemberMaster.MemberID == id).ToList();
                    return(View(model));
                }
                else
                {
                    error.errCode = ErrorDetail.DataImportError;
                    error.errMsg  = ErrorDetail.GetMsg(error.errCode);
                    foreach (var state in ModelState)
                    {
                        foreach (var err in state.Value.Errors)
                        {
                            error.errMsg += ". " + err.ErrorMessage;
                        }
                    }
                    errs.Add("Error #" + error.errCode.ToString() + "!" + error.errMsg);
                    ViewData["AssessmentErrorList"] = errs;
                    return(View(model));
                }
            }

            else if (submit == "Assign") //Adding Person to Activity
            {
                if (ModelState.IsValid)
                {
                    bool?isParticipated = null;
                    if (formCollection["afterTheFact"] == "0")
                    {
                        isParticipated = true;
                    }
                    else if (formCollection["afterTheFact"] == "1")
                    {
                        isParticipated = false;
                    }

                    ActivityByMemberModels activityCRUD = new ActivityByMemberModels();
                    errs = activityCRUD.AddEditActivity(id, ActivityID, ActivityStatusID, isParticipated, model._Activity.ActivityDate, model._Activity.ActivityNote, userId);

                    if (errs == null || errs.Count == 0)
                    {
                        return(RedirectToAction("MembersBySchool", "Home", new { @CollegeID = model._CollegeID }));
                    }
                    else
                    {
                        ViewData["ErrorList"] = errs;

                        ActivityByMemberModels memberActivities = new ActivityByMemberModels();
                        memberActivities.MemberCollection = memberActivities.GetFullListOfMembers();

                        return(View(memberActivities));
                    }
                }
                else
                {
                    error.errCode = ErrorDetail.DataImportError;
                    error.errMsg  = ErrorDetail.GetMsg(error.errCode);
                    foreach (var state in ModelState)
                    {
                        foreach (var err in state.Value.Errors)
                        {
                            error.errMsg += ". " + err.ErrorMessage;
                        }
                    }
                    errs.Add("Error #" + error.errCode.ToString() + "!" + error.errMsg);
                    ViewData["ErrorList"] = errs;

                    ActivityByMemberModels memberActivities = new ActivityByMemberModels();
                    memberActivities.MemberCollection = memberActivities.GetFullListOfMembers();

                    return(View(memberActivities));
                }                //if (ModelState.IsValid)
                //{
                //    try
                //    {
                //        tb_Activity activity = db.tb_Activity.Find(ActivityID);
                //        activity.ActivityDate = model._Activity.ActivityDate;
                //        activity.ActivityNote = model._Activity.ActivityNote;
                //        activity.ModifiedDateTime = DateTime.UtcNow;
                //        activity.ModifiedBy = userId;

                //        tb_MemberActivity oldMemberActivity = db.tb_MemberActivity.Where(p => p.ActivityID == ActivityID && p.MemberID == id).FirstOrDefault(); //id = AssessActivity._Assessment.MemberID (changed to id)
                //        if (oldMemberActivity == null) //Action isnt assigned for this member
                //        {
                //            tb_MemberActivity memberActivity = new tb_MemberActivity();
                //            memberActivity.MemberID = id ?? default(int); //id = AssessActivity._Assessment.MemberID (changed to id);
                //            memberActivity.ActivityID = ActivityID;
                //            memberActivity.ActivityStatusID = ActivityStatusID;
                //            if (ActivityStatusID == 1) // 1 - Committed
                //            {
                //                memberActivity.Membership = true;
                //                memberActivity.MembershipCommitment++;
                //            }
                //            else
                //                memberActivity.Membership = false;

                //            db.tb_MemberActivity.Add(memberActivity);
                //        }
                //        else
                //        {
                //            if (ActivityStatusID == 1) // 1 - Committed
                //            {
                //                oldMemberActivity.Membership = true;
                //                oldMemberActivity.MembershipCommitment++;
                //            }
                //            else
                //            {
                //                oldMemberActivity.Membership = false;
                //                if (oldMemberActivity.ActivityStatusID == 1 && oldMemberActivity.MembershipCommitment > 0) //commited before so reduce qty of commitments
                //                    oldMemberActivity.MembershipCommitment--;
                //            }
                //            oldMemberActivity.ActivityStatusID = ActivityStatusID;
                //            db.Entry(oldMemberActivity).State = EntityState.Modified;
                //        }
                //        db.SaveChanges();
                //        model._MemberActivity = db.tb_MemberActivity.Where(s => s.MemberID == id).ToList();
                //    }
                //    catch (DbEntityValidationException ex)
                //    {
                //        error.errCode = ErrorDetail.DataImportError;
                //        error.errMsg = ErrorDetail.GetMsg(error.errCode);
                //        foreach (DbEntityValidationResult validationError in ex.EntityValidationErrors)
                //        {
                //            error.errMsg += ". Object: " + validationError.Entry.Entity.ToString();
                //            foreach (DbValidationError err in validationError.ValidationErrors)
                //            {
                //                error.errMsg += ". " + err.ErrorMessage;
                //            }
                //        }
                //        errs.Add("Error #" + error.errCode.ToString() + "!" + error.errMsg);
                //        ViewData["ActivityErrorList"] = errs;
                //        return View(model);
                //    }
                //}
            }
            else
            {
                error.errCode = ErrorDetail.DataImportError;
                error.errMsg  = ErrorDetail.GetMsg(error.errCode);
                foreach (var state in ModelState)
                {
                    foreach (var err in state.Value.Errors)
                    {
                        error.errMsg += ". " + err.ErrorMessage;
                    }
                }
                errs.Add("Error #" + error.errCode.ToString() + "!" + error.errMsg);
                ViewData["ActivityErrorList"] = errs;
                return(View(model));
            }

            return(View(model));
            //return RedirectToAction("AddPersonAssessmentActivity");
        }
Esempio n. 5
0
        public ActionResult AddActivityByMember([Bind(Include = "ActivityID")] ActivityByMemberModels model, FormCollection formCollection)
        {
            Error error = new Error();

            error.errCode = ErrorDetail.Success;
            List <string> errs = new List <string>();

            bool result = Int32.TryParse(formCollection["MemberID"], out int mId); //MemberActivityID

            model.MemberID         = mId;
            result                 = Int32.TryParse(formCollection["ActivityStatusID"], out int asID); //ActivityStatusID  (Before The Fact)
            model.ActivityStatusID = asID;

            #region Prepare Model
            ViewBag.ActivityStatus      = db.tb_ActivityStatus.ToList();
            ViewBag.ActivityStatusAfter = new List <SelectListItem>
            {
                new SelectListItem {
                    Value = "0", Text = "Participated", Selected = false
                },
                new SelectListItem {
                    Value = "1", Text = "Not Participated", Selected = false
                }
            };

            SelectList     Activities  = new SelectList(db.tb_Activity.OrderBy(s => s.ActivityName), "ActivityID", "ActivityName");
            SelectListItem selListItem = new SelectListItem()
            {
                Value = "0", Text = " Select Activity "
            };
            ViewBag.ActivityID = CommonFunctions.AddFirstItem(Activities, selListItem);
            #endregion

            if (ModelState.IsValid)
            {
                bool?isParticipated = null;
                if (formCollection["afterTheFact"] == "0")
                {
                    isParticipated = true;
                }
                else if (formCollection["afterTheFact"] == "1")
                {
                    isParticipated = false;
                }

                string userId = HttpContext.GetOwinContext().Authentication.User.Identity.GetUserId();

                ActivityByMemberModels activityCRUD = new ActivityByMemberModels();
                errs = activityCRUD.AddEditActivity(model.MemberID, model.ActivityID, model.ActivityStatusID, isParticipated, DateTime.Parse(formCollection["tb_Activity.ActivityDate"]), formCollection["tb_Activity.ActivityNote"], userId);

                if (errs == null || errs.Count == 0)
                {
                    return(RedirectToAction("Index", "Activities", new { @id = model.MemberID }));
                }
                else
                {
                    ViewData["ErrorList"] = errs;

                    ActivityByMemberModels memberActivities = new ActivityByMemberModels();
                    memberActivities.MemberCollection = memberActivities.GetFullListOfMembers();

                    return(View(memberActivities));
                }
            }
            else
            {
                error.errCode = ErrorDetail.DataImportError;
                error.errMsg  = ErrorDetail.GetMsg(error.errCode);
                foreach (var state in ModelState)
                {
                    foreach (var err in state.Value.Errors)
                    {
                        error.errMsg += ". " + err.ErrorMessage;
                    }
                }
                errs.Add("Error #" + error.errCode.ToString() + "!" + error.errMsg);
                ViewData["ErrorList"] = errs;

                ActivityByMemberModels memberActivities = new ActivityByMemberModels();
                memberActivities.MemberCollection = memberActivities.GetFullListOfMembers();

                return(View(memberActivities));
            }
        }