Exemple #1
0
        public JsonResult SaveStudent(tblStudent data)
        {
            data.Active          = (Request.Form["Active"] == "on");
            data.subsidy         = (Request.Form["subsidy"] == "on");
            data.siblingAtSchool = (Request.Form["siblingAtSchool"] == "on");
            data.GetAlertByEmail = (Request.Form["GetAlertByEmail"] == "on");
            data.GetAlertByCell  = (Request.Form["GetAlertByCell"] == "on");
            data.specialRequest  = (Request.Form["specialRequest"] == "on");
            if (data.pk == 0)
            {
                tblStudentLogic.create(data);
            }
            else
            {
                using (var logic = new tblStudentLogic())
                {
                    var st = logic.getStudentByPk(data.pk);
                    if (st.city != data.city || st.street != data.street || st.houseNumber != data.houseNumber)
                    {
                        //address changed
                        st.Lat = null;
                        st.Lng = null;
                        st.distanceFromSchool = 0;
                    }

                    st.familyId        = data.familyId;
                    st.siblingAtSchool = data.siblingAtSchool;
                    st.firstName       = data.firstName;
                    st.lastName        = data.lastName;
                    st.@class          = data.@class;
                    st.Shicva          = data.Shicva;
                    st.city            = data.city;
                    st.street          = data.street;
                    st.houseNumber     = data.houseNumber;
                    st.zipCode         = data.zipCode;
                    st.Email           = data.Email;
                    st.GetAlertByEmail = data.GetAlertByEmail;
                    st.CellPhone       = data.CellPhone;
                    st.GetAlertByCell  = data.GetAlertByCell;
                    st.specialRequest  = data.specialRequest;
                    st.request         = data.request;
                    st.Active          = data.Active;
                    st.subsidy         = data.subsidy;
                    st.streetId        = data.streetId;
                    st.cityId          = data.cityId;

                    tblStudentLogic.update(st);
                }
            }

            return(null);
        }
Exemple #2
0
 public ActionResult update(studentViewModel c)
 {
     if (c != null)
     {
         using (tblStudentLogic student = new tblStudentLogic())
         {
             int        familyId = (int)Session["familyId"];
             tblStudent v        = student.getStudentByPk(c.EditableTblStudents.pk);
             if (v.familyId == familyId && v.pk == c.EditableTblStudents.pk)//familiy from session + check if its the same student
             {
                 if (v.street != c.EditableTblStudents.street || v.houseNumber != c.EditableTblStudents.houseNumber)
                 {
                     v.registrationStatus = false;//Must Have administration confirm for changing the buss station for student
                 }
                 v.street = c.EditableTblStudents.street;
                 if (!checkstreet(c.EditableTblStudents.street))
                 {
                     ViewBag.message = DictExpressionBuilderSystem.Translate("message.selectStreetFromList");
                     return(View(c));
                 }
                 v.houseNumber = c.EditableTblStudents.houseNumber;
                 v.Shicva      = c.EditableTblStudents.Shicva;
                 v.@class      = c.EditableTblStudents.@class;
                 v.subsidy     = c.EditableTblStudents.subsidy;
                 if (v.Email != c.EditableTblStudents.Email)
                 {
                     v.Email           = c.EditableTblStudents.Email;
                     v.GetAlertByEmail = c.EditableTblStudents.GetAlertByEmail;
                     v.EmailConfirm    = false;
                 }
                 if (v.CellPhone != c.EditableTblStudents.CellPhone)
                 {
                     v.CellPhone      = c.EditableTblStudents.CellPhone;
                     v.GetAlertByCell = c.EditableTblStudents.GetAlertByCell;
                     v.CellConfirm    = false;
                 }
                 //Task<tblStudent> x = geoCoding(v);
                 //v.Lng = x.Result.Lng;
                 //v.Lat = x.Result.Lat;
                 v.lastUpdate = DateTime.Today;
                 tblStudentLogic.update(v);
             }
         }
         return(RedirectToAction("index", "Family"));
     }
     else
     {
         return(Redirect("~/account/unAutorise"));//real check is by Js in client side- if we here there is asecurity problem!
     }
 }
Exemple #3
0
        public string GetStudent(string id)
        {
            tblStudent res = null;

            using (var logic = new tblStudentLogic())
            {
                int iid;
                if (int.TryParse(id, out iid))
                {
                    res = logic.getStudentByPk(iid);
                }
            }
            return(JsonConvert.SerializeObject(res));
        }
        public AttachStudentResultModel PostAddress(StudentAddressViewModel data)
        {
            var res = new AttachStudentResultModel
            {
                Done     = false,
                Lines    = new List <LineModel>(),
                Stations = new List <StationModel>()
            };

            try
            {
                using (var logic = new tblStudentLogic())
                {
                    var st = logic.getStudentByPk(data.StudentId);
                    if (st != null)
                    {
                        if (st.cityId != data.CityId ||
                            st.streetId != data.StreetId ||
                            st.houseNumber != data.HouseNumber)
                        {
                            st.street      = data.Street;
                            st.streetId    = data.StreetId;
                            st.city        = data.City;
                            st.cityId      = data.CityId;
                            st.houseNumber = data.HouseNumber;
                            st.Lat         = null;
                            st.Lng         = null;
                            tblStudentLogic.update(st);

                            //disconnect from all lines
                            var detachResult = logic.RemoveStudentFromAllStations(st.pk);
                            res.Student = new StudentShortInfo(st);

                            res.Stations = detachResult.Stations.Select(d => new StationModel(d)).ToList();
                            res.Lines    = detachResult.Lines.Select(d => new LineModel(d)).ToList();

                            res.Done = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                res.Done = false;
            }
            return(res);
        }
Exemple #5
0
        public JsonResult StudentsForFTable(GridSettings grid)
        {
            var total     = 0;
            var logic     = new tblStudentLogic();
            var familyId  = 0;
            int?studentId = null;

            if (Request["familyId"] != null)
            {
                familyId = Int32.Parse(Request["familyId"]);
            }
            else
            {
                studentId = Int32.Parse(Request["studentId"]);
                var st = logic.getStudentByPk(studentId.Value);
                familyId = st.familyId;
            }

            var lst = logic.GetStudentsForFamily(familyId, studentId, grid.PageIndex, grid.PageSize, grid.SortColumn,
                                                 grid.SortOrder, out total);
            var jsonData = new
            {
                total   = (int)Math.Ceiling((double)total / grid.PageSize),
                page    = grid.PageIndex,
                records = total,
                rows    = (from stud in lst
                           select
                           new
                {
                    id = stud.Id,
                    cell = new string[] {
                        stud.StudentId,
                        stud.Name,
                        stud.Class,
                        stud.Shicva,
                        stud.Address
                    }
                })
            };
            var r = new JsonResult {
                Data = jsonData
            };

            return(r);
        }
Exemple #6
0
        public ActionResult update(int id)//id= studentPk
        {
            int studentPk = id;
            int familyId  = (int)Session["familyId"];

            // int familyId = 11;//todo  take from session
            // int yearRegistration = 2017;///todo  take from cache
            //check if this studentPk has familyId the same as in the sessio-else return null
            using (tblStudentLogic student = new tblStudentLogic())
            {
                tblStudent c = student.getStudentByPk(studentPk);
                if (c == null || c.familyId != familyId)//for security
                {
                    return(null);
                }
                //   tblStreet r = new Business_Logic.tblStreet();

                List <tblStreet> s = new List <tblStreet>();//TODO get tblStreet from cache

                studentViewModel vm = new studentViewModel()
                {
                    EditableTblStudents = c,
                    CellConfirm         = c.CellConfirm.HasValue ? c.CellConfirm.Value : false,
                    GetAlertByCell      = c.GetAlertByCell.HasValue ? c.GetAlertByCell.Value : false,
                    EmailConfirm        = c.EmailConfirm.HasValue ? c.EmailConfirm.Value : false,
                    GetAlertByEmail     = c.GetAlertByEmail.HasValue ? c.GetAlertByEmail.Value : false,
                    paymentStatus       = c.paymentStatus.HasValue ? c.paymentStatus.Value : false,
                    siblingAtSchool     = c.siblingAtSchool.HasValue ? c.siblingAtSchool.Value : false,
                    specialRequest      = c.specialRequest.HasValue ? c.specialRequest.Value : false,
                    clas = student.clas()
                };
                return(View(vm));
            }

            //get family name from tblFamily
            //get list of street to viewbag from cashe
            //check if the student was register last year get the relevant data- it may be the same student
            //else shceck if student has brothers - take the relevant data

            //show  view  with the relevant data
        }
        public StudentAddressViewModel GetAddress(int id)
        {
            StudentAddressViewModel res = null;

            using (var logic = new tblStudentLogic())
            {
                var st = logic.getStudentByPk(id);
                if (st != null)
                {
                    res = new StudentAddressViewModel
                    {
                        StudentId   = st.pk,
                        City        = st.city,
                        CityId      = st.cityId ?? 0,
                        Street      = st.street,
                        StreetId    = st.streetId ?? 0,
                        HouseNumber = st.houseNumber,
                        Confirm     = st.registrationStatus
                    };
                }
            }
            return(res);
        }
Exemple #8
0
        public AttachStudentResultModel PostAttachStudent(AttachStudentModel model)
        {
            var        res = new AttachStudentResultModel();
            List <int> stations;
            List <int> lines;
            DateTime?  date = null;

            if (!string.IsNullOrEmpty(model.StrDate))
            {
                var dtList = model.StrDate.Split('/');
                if (dtList.Length == 3)
                {
                    date = new DateTime(
                        int.Parse(dtList[2]),
                        int.Parse(dtList[0]),
                        int.Parse(dtList[1]),
                        model.Hours,
                        model.Minutes, 0);
                }
            }
            var wd = new WeekDays
            {
                Monday    = model.Mon == "on",
                Tuesday   = model.Tue == "on",
                Wednesday = model.Wed == "on",
                Thursday  = model.Thu == "on",
                Friday    = model.Fri == "on",
                Saturday  = model.Sat == "on",
                Sunday    = model.Sun == "on"
            };

            using (var logic = new tblStudentLogic())
            {
                var oldList = logic.GetAttachInfo(model.StudentId);
                stations = oldList.Select(z => z.StationId).ToList();
                lines    = oldList.Where(z => z.LineId != -1).Select(z => z.LineId).ToList();
            }
            using (var logic = new StationsLogic())
            {
                res.Done = logic.AttachStudent(
                    model.StudentId,
                    model.StationId,
                    model.LineId,
                    model.Distance,
                    (ColorMode)model.UseColor,
                    date,
                    model.ConflictAction,
                    wd);
            }
            using (var logic = new tblStudentLogic())
            {
                var newList = logic.GetAttachInfo(model.StudentId);
                stations.AddRange(newList.Select(z => z.StationId).ToList());
                lines.AddRange(newList.Where(z => z.LineId != -1).Select(z => z.LineId).ToList());

                res.Student = new StudentShortInfo(logic.getStudentByPk(model.StudentId));
            }
            using (var logic = new StationsLogic())
            {
                res.Stations = logic.GetStations(stations)
                               .Select(z => new StationModel(z)).ToList();
                foreach (var station in res.Stations)
                {
                    station.Students = logic.GetStudents(station.Id)
                                       .Select(z => new StudentToLineModel(z))
                                       .ToList();
                }
            }
            using (var logic = new LineLogic())
            {
                res.Lines = logic.GetLines(lines).Select(z => new LineModel(z)).ToList();
                foreach (var line in res.Lines)
                {
                    line.Stations = logic.GetStations(line.Id)
                                    .Select(z => new StationToLineModel(z))
                                    .ToList();
                }
            }
            return(res);
        }