コード例 #1
0
        public JsonResult PickupNewStudent(int Id)
        {
            string status = "";
            NewStudentViewModel student = null;

            var s = db.NewStudents.FirstOrDefault(o => o.Id == Id);

            var currVol = GetCurrentVolunteer();

            if ((s.Organization == null) || (currVol.OrganizationId != s.Organization.Id))
            {
                status = "out-group";
                goto exit;
            }

            if (currVol.Organization.ModelType == OrgModelType.IntGrouped)
            {
                if (s.Group == null || currVol.GroupId != s.Group.Id)
                {
                    status = "out-group";
                    goto exit;
                }
            }

            if (s.ManualAssignInfoes != null && s.ManualAssignInfoes.Count > 0)
            {
                var pickManualAssign = s.ManualAssignInfoes.Where(m => m.Type == ManualAssignType.IntPickup).SingleOrDefault();
                if (pickManualAssign != null)
                {
                    status = "pickup-assigned";
                    goto exit;
                }
            }

            if (s.NeedPickup == false)
            {
                status = "pickup-no-need";
                goto exit;
            }
            else if (s.PickupVolunteer != null)
            {
                status = "pickup-assigned";
                goto exit;
            }

            currVol.PickupNewStudents.Add(s);
            db.SaveChanges();

            student = NewStudentListOps._GetOneNewStudent(Id);

exit:
            return(Json(new { status = status, student = student }, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public ActionResult _SaveNewStudentAjaxEditing(int id)
        {
            var student = NewStudentListOps._GetOneNewStudent(id);

            TryUpdateModel(student);
            NewStudent s = db.NewStudents.Find(id);

            s = student.UpdateNewStudentModel(s);
            db.Entry(s).State = EntityState.Modified;
            db.SaveChanges();
            return(_OrgVolunteerList(s.Organization.Id));
        }
コード例 #3
0
        public JsonResult TempHousingNewStudent(int Id)
        {
            string status = "";
            NewStudentViewModel student = null;
            var s = db.NewStudents.FirstOrDefault(o => o.Id == Id);

            var currVol = GetCurrentVolunteer();

            if (s.Organization == null || currVol.OrganizationId != s.Organization.Id)
            {
                status = "out-group";
                goto exit;
            }

            if (currVol.Organization.ModelType == OrgModelType.IntGrouped)
            {
                if (s.Group == null || currVol.GroupId != s.Group.Id)
                {
                    status = "out-group";
                    goto exit;
                }
            }

            if (s.ManualAssignInfoes != null && s.ManualAssignInfoes.Count > 0)
            {
                var housingManualAssign = s.ManualAssignInfoes.Where(m => m.Type == ManualAssignType.IntHousing).SingleOrDefault();

                if (housingManualAssign != null)
                {
                    status = "housing-assigned";
                    goto exit;
                }
            }

            if (s.NeedTempHousing == false)
            {
                status = "housing-no-need";
                goto exit;
            }
            else if (s.TempHouseVolunteer != null)
            {
                status = "housing-assigned";
                goto exit;
            }

            if (currVol.Gender != SystemGender.Family)
            {
                if (currVol.Gender != s.Gender)
                {
                    status = "different-gender";
                    goto exit;
                }
            }

            currVol.TempHouseNewStudents.Add(s);
            db.SaveChanges();

            student = NewStudentListOps._GetOneNewStudent(Id);

exit:
            return(Json(new { status = status, student = student }, JsonRequestBehavior.AllowGet));
        }