示例#1
0
        public void deleteStaffBySchool(schools record)
        {
            var staff = (from e in record.staff_by_schools
                         where e.school_code == record.code
                         select e).ToList<staff_by_schools>();

            foreach (staff_by_schools item in staff)
            {
                fmp.staff_by_schools.Remove(item);
            }
        }
示例#2
0
        public IHttpActionResult saveSchool([FromBody]dynamic school)
        {
            try
            {
                bool updating = false;
                string school_code = school.code;
                schools record = (from s in fmp.schools
                                  where s.code == school_code
                                  select s).FirstOrDefault<schools>();

                if (record == null)
                {
                    record = new schools();
                }
                else
                {
                    deleteStaffBySchool(record);
                    updating = true;
                }

                record.code = school.code;
                record.location = school.location;
                record.size = school.size;
                record.employee_manager = school.employee_manager;
                record.supervisor = school.supervisor;
                record.name = school.name;
                record.budget = school.budget;

                parseStaffSchool(ref record, school.employees);

                if (!updating) { fmp.schools.Add(record); }
                fmp.SaveChanges();
                return Ok(1);
            }
            catch (Exception ex)
            {
                return InternalServerError(ex);
            }
        }
示例#3
0
 public void parseStaffSchool(ref schools school, dynamic employees)
 {
     foreach (dynamic item in employees)
     {
         staff_by_schools sbs = new staff_by_schools();
         sbs.status = item.status;
         sbs.school_code = school.code;
         sbs.employee_code = item.employee_code;
         sbs.order = item.order;
         school.staff_by_schools.Add(sbs);
     }
 }