public ActionResult MigrateAreas()
        {

            var instructorList = _instructorRepo.TblInstructors.ToList();
            foreach (var instructor in instructorList )
            {
                if (!string.IsNullOrEmpty(instructor.AreaIds))
                {
                    string[] areas = instructor.AreaIds.Split(',');
                    foreach (var area in areas)
                    {

                        var instructorArea = _instructorRepo.GetInstructorArea(instructor.InstructorId,
                            Convert.ToInt32(area));
                        if (instructorArea == null)
                            instructorArea = new TblInstructorArea {InstructorId = instructor.InstructorId,AreaId = Convert.ToInt32(area)};

                        _instructorRepo.SaveInstructorArea(instructorArea);
                    }
                }
            }
            return View("");
        }
示例#2
0
 public void SaveInstructorArea(TblInstructorArea model)
 {
     var instructorarea =
         DataContext.InstructorAreas.SingleOrDefault(
             s => s.AreaId == model.AreaId && s.InstructorID == model.InstructorId) ?? new InstructorArea();
     instructorarea.AreaId = model.AreaId;
     instructorarea.InstructorID = model.InstructorId;
     if (instructorarea.Id == 0)
         DataContext.InstructorAreas.Add(instructorarea);
     SaveInDatabase();
 }