public override void Seed() { System.Diagnostics.Debug.Print("Seeding db"); var instructor1 = Instructors.Add(new Instructor { ID = 10, IsDeleted = true, HireDate = new DateTime(2015, 2, 1) }); var instructor2 = Instructors.Add(new Instructor { ID = 11, IsDeleted = false, HireDate = new DateTime(2015, 2, 2) }); var instructor3 = Instructors.Add(new Instructor { ID = 12, IsDeleted = false, HireDate = new DateTime(2015, 2, 3) }); Students.Add(new Student { ID = 1, IsDeleted = false, EnrollmentDate = new DateTime(2015, 1, 1), Instructor = instructor1 }); Students.Add(new Student { ID = 2, IsDeleted = true, EnrollmentDate = new DateTime(2015, 1, 2), Instructor = instructor2 }); Students.Add(new Student { ID = 3, IsDeleted = false, EnrollmentDate = new DateTime(2015, 1, 3), Instructor = instructor3 }); Residents.Add(new Resident { Created = new DateTime(2015, 1, 1), CreatedBy = "me", Id = 1, FirstName = "Fred", LastName = "Flintstone", Title = "Mr", FamiliarName = "Fred", Gender = "M" }); Residents.Add(new Resident { Created = new DateTime(2015, 2, 1), CreatedBy = "me", Deleted = new DateTime(2015, 2, 3), Id = 2, FirstName = "Barney", LastName = "Rubble", Title = "Mr", FamiliarName = "Barney", Gender = "M" }); SaveChanges(); }
public ResultSvc <Instructor> CreateInstructor(Instructor instructor) { var result = new ResultSvc <Instructor>(instructor); try { if (!Instructors.Items.Any(x => x.Firstname == instructor.Firstname.Trim() && x.Lastname == instructor.Lastname.Trim() && (!string.IsNullOrEmpty(instructor.Title) && x.Title == instructor.Title.Trim()))) { instructor.Firstname = instructor.Firstname?.Trim(); instructor.Lastname = instructor.Lastname?.Trim(); instructor.Title = instructor.Title?.Trim(); instructor.Description = instructor.Description?.Trim(); instructor.Email = instructor.Email?.Trim(); instructor.Phone = instructor.Phone?.Trim(); instructor.Facebook = instructor.Facebook?.Trim(); instructor.UserCreatedId = Context.HttpContext.User.GetUserId(); Instructors.Add(instructor); } else { result.Errors.Add("Tento instruktor již existuje!"); } } catch (Exception e) { Logger.LogError(e.Message); } return(result); }
public override void Seed() { System.Diagnostics.Debug.Print("Seeding db"); var instructor1 = Instructors.Add(new Instructor { ID = 10, IsDeleted = true, HireDate = new DateTime(2015, 2, 1) }); var instructor2 = Instructors.Add(new Instructor { ID = 11, IsDeleted = false, HireDate = new DateTime(2015, 2, 2) }); var instructor3 = Instructors.Add(new Instructor { ID = 12, IsDeleted = false, HireDate = new DateTime(2015, 2, 3) }); Students.Add(new Student { ID = 1, IsDeleted = false, EnrollmentDate = new DateTime(2015, 1, 1), Instructor = instructor1 }); Students.Add(new Student { ID = 2, IsDeleted = true, EnrollmentDate = new DateTime(2015, 1, 2), Instructor = instructor2 }); Students.Add(new Student { ID = 3, IsDeleted = false, EnrollmentDate = new DateTime(2015, 1, 3), Instructor = instructor3 }); SaveChanges(); }
public bool CreateInstructor(Instructor instructor, string userId) { try { if (!Instructors.Items.Any(x => x.Firstname == instructor.Firstname.Trim() && x.Surname == instructor.Surname.Trim())) { instructor.Firstname = instructor.Firstname.Trim(); instructor.Surname = instructor.Surname.Trim(); instructor.UserCreated = userId; instructor.Order = Instructors.Items.Select(x => x.Order).DefaultIfEmpty(0).Max() + 1; foreach (var l in instructor.Languages) { l.LanguageLevel = LanguageLevels.FindById(l.LanguageLevelId); } var languages = new List <InstructorLanguage>(instructor.Languages); foreach (var l in languages) { if (instructor.Languages.Any(x => x.LanguageId == l.LanguageId && x.LanguageLevel.Level > l.LanguageLevel.Level)) { instructor.Languages.Remove(l); } } foreach (var e in instructor.Expertises) { e.ExpertiseLevel = ExpertiseLevels.FindById(e.ExpertiseLevelId); } var expertises = new List <InstructorExpertise>(instructor.Expertises); foreach (var e in expertises) { if (instructor.Expertises.Any(x => x.ExpertiseId == e.ExpertiseId && x.ExpertiseLevel.Level > e.ExpertiseLevel.Level)) { instructor.Expertises.Remove(e); } } foreach (var ticket in instructor.Tickets) { ticket.From = ticket.From.Date; ticket.To = ticket.To.Date; } Instructors.Add(instructor); return(true); } } catch (Exception e) { } return(false); }
public Section(string course, string name, int openSeats, int waitList, params KeyValuePair <string, Class>[] classes) { Course = course; Name = name; OpenSeats = openSeats; WaitList = waitList; foreach (var myClass in classes) { Classes.Add(myClass.Key, myClass.Value); if (!Instructors.ContainsKey(myClass.Value.Instructor)) { Instructors.Add(myClass.Value.Instructor, true); } } }
public Section(string course, string name, int openSeats, int waitList, params ClassSequence[] classTypesAndSchedules) { Course = course; Name = name; OpenSeats = openSeats; WaitList = waitList; foreach (var myClass in classTypesAndSchedules) { ClassSequences.Add(myClass); if (!Instructors.Contains(myClass.Instructor)) { Instructors.Add(myClass.Instructor); } } }
public virtual void AddInstructor(Instructor instructor) { Instructors.Add(instructor); }