Пример #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));
        }
Пример #2
0
        public ActionResult AddNote([Bind(Include = "_MemberID,_Note,_NoteDate,_NoteTypeID,_TakenBy")] AddNoteModel model)
        {
            Error error = new Error();

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

            try
            {
                tb_MemberNotes memberNote = new tb_MemberNotes()
                {
                    MemberID      = model._MemberID,
                    Notes         = model._Note,
                    NoteDate      = model._NoteDate,
                    NoteTypeID    = model._NoteTypeID,
                    TakenBy       = model._TakenBy,
                    AddedDateTime = DateTime.UtcNow
                };
                db.tb_MemberNotes.Add(memberNote);

                model._NoteTypes = new SelectList(db.tb_NoteType, "NoteTypeID", "NoteType");
                ViewBag._TakenBy = new SelectList(db.AspNetUsers.OrderBy(s => s.LastFirstName), "Id", "LastFirstName");
                tb_MemberMaster fm = db.tb_MemberMaster.Find(model._MemberID);
                ViewBag.MemberName = fm.FirstName + " " + fm.LastName;
                model._MemberNotes = db.tb_MemberNotes.Where(t => t.MemberID == model._MemberID).ToList(); //before
                db.SaveChanges();
                model._MemberNotes = db.tb_MemberNotes.Where(t => t.MemberID == model._MemberID).ToList(); //after
            }
            catch (Exception ex)
            {
                error.errCode = ErrorDetail.DataImportError;
                error.errMsg  = ErrorDetail.GetMsg(error.errCode);
                errs.Add("Error #" + error.errCode.ToString() + "!" + error.errMsg + ". " + ex.Message);
                ViewData["ErrorList"] = errs;
                return(View(model));
            }

            return(View(model));
        }
Пример #3
0
        public ActionResult AddNote(int?id)
        {
            //id = 1; // test REMOVE IT
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AddNoteModel model = new AddNoteModel()
            {
                _MemberID    = id ?? 0,
                _NoteDate    = DateTime.Now,
                _NoteTypeID  = 1,
                _NoteTypes   = new SelectList(db.tb_NoteType, "NoteTypeID", "NoteType"),
                _MemberNotes = db.tb_MemberNotes.Where(t => t.MemberID == id).ToList()
            };

            ViewBag._TakenBy = new SelectList(db.AspNetUsers.OrderBy(s => s.LastFirstName), "Id", "LastFirstName");
            tb_MemberMaster fm = db.tb_MemberMaster.Find(id);

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

            return(View(model));
        }
Пример #4
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));
        }
Пример #5
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");
        }