public async Task <ActionResult <int?> > AddCity([FromBody] CityInputModel model) { if (model == null) { return(BadRequest()); } City dataModel = CityMapper.ToDataModel(model); int? id = await dictionaryStorage.CityAddOrUpdate(dataModel); return(Ok(id)); }
private void CitySetup() { foreach (City item in DictionaryMocks.cityMock) { City newCity = (City)item.Clone(); newCity.Id = null; listCity.Add(newCity); } for (int i = 0; i < listCity.Count; i++) { int id = (int)dictionaryStorage.CityAddOrUpdate(listCity[i]).Result; listCity[i].Id = id; } }
private async Task Setup() { listJournal.AddRange(JournalMock.journalMocks); listCity.AddRange(DictionaryMocks.cityMock.Select(m => (City)m.Clone())); listUser.AddRange(UserMock.listUsers.Select(u => (User)u.Clone())); listCourseProgram.AddRange(CourseProgramMock.listCourseProgram.Select(m => (CourseProgram)m.Clone())); listGroup.AddRange(GroupMock.groupMocks.Select(m => (Group)m.Clone())); listLesson.AddRange(LessonMock.lessonMocks.Select(m => (Lesson)m.Clone())); listCourse.AddRange(CourseMock.listCourse.Select(m => (Course)m.Clone())); for (int i = 0; i < listJournal.Count; i++) { listCity[i].Id = await dictionaryStorage.CityAddOrUpdate(listCity[i]); listUser[i].CityId = (int)listCity[i].Id; listUser[i].Id = await userStorage.UserAddOrUpdate(listUser[i]); listCourse[i].Id = await courseStorage.CourseAddOrUpdate(listCourse[i]); listCourseProgram[i].CourseId = (int)listCourse[i].Id; listCourseProgram[i].Id = await courseStorage.CourseProgramAddOrUpdate(listCourseProgram[i]); listGroup[i].CourseProgramId = (int)listCourseProgram[i].Id; listGroup[i].Id = await groupStorage.GroupAddOrUpdate(listGroup[i]); listLesson[i].GroupId = (int)listGroup[i].Id; listLesson[i].Id = await lessonStorage.AddOrUpdateLesson(listLesson[i]); listJournal[i].LessonID = (int)listLesson[i].Id; listJournal[i].UserId = (int)listUser[i].Id; listJournal[i].Id = await lessonStorage.AddOrUpdateJournal(listJournal[i]); } }
public async Task Setup() { listTeacherGroup.AddRange(TeacherGroupMock.listTeacherGroup); listCity = DictionaryMocks.cityMock; listUser = UserMock.listUsers; listCourseProgram = CourseProgramMock.listCourseProgram; listGroup = GroupMock.groupMocks; listCourses = CourseMock.listCourse; for (int i = 0; i < listTeacherGroup.Count; i++) { listCity[i].Id = await dictionaryStorage.CityAddOrUpdate(listCity[i]); listUser[i].CityId = (int)listCity[i].Id; listUser[i].Id = await userStorage.UserAddOrUpdate(listUser[i]); listCourses[i].Id = await courseStorage.CourseAddOrUpdate(listCourses[i]); listCourseProgram[i].CourseId = (int)listCourses[i].Id; listCourseProgram[i].Id = await courseStorage.CourseProgramAddOrUpdate(listCourseProgram[i]); listGroup[i].CourseProgramId = (int)listCourseProgram[i].Id; listGroup[i].Id = await groupStorage.GroupAddOrUpdate(listGroup[i]); listTeacherGroup[i].UserId = (int)listCity[i].Id; listTeacherGroup[i].GroupId = (int)listGroup[i].Id; listTeacherGroup[i].Id = await groupStorage.TeacherGroupInsert(listTeacherGroup[i]); } }
public async Task Setup() { listUser.AddRange(UserMock.listUsers.Select(x => (User)x.Clone())); listCity.AddRange(DictionaryMocks.cityMock.Select(x => (City)x.Clone())); for (int i = 0; i < listCity.Count; i++) { City newCity = (City)DictionaryMocks.cityMock[i].Clone(); listCity.Add(newCity); int cityId = (int)(await dictionaryStorage.CityAddOrUpdate(listCity[i])); listCity[i].Id = cityId; User newUser = (User)UserMock.listUsers[i].Clone(); listUser.Add(newUser); listUser[i].CityId = cityId; int?id = await userStorage.UserAddOrUpdate(listUser[i]); listUser[i].Id = id; listUser[i].City = listCity[i]; listUser[i].Roles = null; listUser[i].StudentGroup = null; listUser[i].Skills = null; User tempUser = await userStorage.UserSelectById(id); listUser[i].RegistrationDate = tempUser.RegistrationDate; } }
private void Setup() { foreach (City item in DictionaryMocks.cityMock) { City newCity = (City)item.Clone(); newCity.Id = null; listCity.Add(newCity); } for (int i = 0; i < listCity.Count; i++) { int id = (int)dictionaryStorage.CityAddOrUpdate(listCity[i]).Result; listCity[i].Id = id; } foreach (Role item in DictionaryMocks.roleMocks) { Role newRole = (Role)item.Clone(); newRole.Id = null; listRole.Add(newRole); } for (int i = 0; i < listRole.Count; i++) { int id = (int)dictionaryStorage.RoleAddOrUpdate(listRole[i]).Result; listRole[i].Id = id; } foreach (User item in UserMock.listUsers) { User newUser = (User)item.Clone(); newUser.CityId = (int)listCity[0].Id; newUser.Id = null; listUser.Add(newUser); } for (int i = 0; i < listUser.Count; i++) { int id = (int)userStorage.UserAddOrUpdate(listUser[i]).Result; listUser[i].Id = id; } foreach (User_Role item in User_RoleMock.user_RoleMocks) { User_Role newUser_Role = (User_Role)item.Clone(); newUser_Role.Id = null; listUser_role.Add(newUser_Role); } for (int i = 0; i < listUser_role.Count; i++) { listUser_role[i].RoleId = (int)listRole[i].Id; listUser_role[i].UserId = (int)listUser[i].Id; int id = (int)userStorage.User_RoleAdd(listUser_role[i]).Result; listUser_role[i].Id = id; } }
private async Task Setup() { listNews = new List <News>(NewsMock.listNews.Select(x => (News)x.Clone())); user1 = (User)UserMock.listUsers[0].Clone(); user2 = (User)UserMock.listUsers[1].Clone(); group = (Group)GroupMock.groupMocks[0].Clone(); course = (Course)CourseMock.listCourse[0].Clone(); courseProgram = (CourseProgram)CourseProgramMock.listCourseProgram[0].Clone(); city = (City)DictionaryMocks.cityMock[0].Clone(); var createdCityId = await dictionaryStorage.CityAddOrUpdate(city); user1.CityId = (int)createdCityId; user2.CityId = (int)createdCityId; listNews[0].AuthorId = await userStorage.UserAddOrUpdate(user1); listNews[0].RecipientID = await userStorage.UserAddOrUpdate(user2); listNews[1].AuthorId = await userStorage.UserAddOrUpdate(user2); courseProgram.CourseId = await courseStorage.CourseAddOrUpdate(course); group.CourseProgramId = await courseStorage.CourseProgramAddOrUpdate(courseProgram); listNews[1].GroupID = await groupStorage.GroupAddOrUpdate(group); for (int i = 0; i < listNews.Count; i++) { News inputmodel = new News() { AuthorId = listNews[i].AuthorId, Content = listNews[i].Content, GroupID = listNews[i].GroupID, Id = listNews[i].Id, PublicationDate = listNews[i].PublicationDate, RecipientID = listNews[i].RecipientID, Title = listNews[i].Title }; int id = await newsStorage.NewsAddOrUpdate(inputmodel); listNews[i].Id = id; listNews[i].PublicationDate = (await newsStorage.NewsGetById(id)).PublicationDate; } }
public async void Setup() { DictionaryMocks.cityMock[0].Id = dictionaryStorage.CityAddOrUpdate(DictionaryMocks.cityMock[0]).Result; UserMock.listUsers[0].CityId = (int)DictionaryMocks.cityMock[0].Id; UserMock.listUsers[0].Id = await userStorage.UserAddOrUpdate(UserMock.listUsers[0]); CourseMock.listCourse[0].Id = await courseStorage.CourseAddOrUpdate(CourseMock.listCourse[0]); CourseProgramMock.listCourseProgram[0].CourseId = (int)CourseMock.listCourse[0].Id; CourseProgramMock.listCourseProgram[0].Id = await courseStorage.CourseProgramAddOrUpdate(CourseProgramMock.listCourseProgram[0]); listCourseProgramSkill = CourseProgramSkillMocks.listCourseProgramSkill; listCourseProgramSkill[0].CourseProgramId = (int)CourseProgramMock.listCourseProgram[0].Id; listCourseProgramSkill[0].Id = await courseStorage.CourseProgramSkillAddOrUpdate(listCourseProgramSkill[0]); UserSkillMock.listUserSkill[0].UserId = (int)UserMock.listUsers[0].Id; UserSkillMock.listUserSkill[0].SkillId = (int)listCourseProgramSkill[0].Id; UserSkillMock.listUserSkill[0].Id = await userStorage.UserSkillAdd(UserSkillMock.listUserSkill[0]); }
public async void Setup() { listStudentGroup.AddRange(StudentGroupMock.listStudentGroup); for (int i = 0; i < listStudentGroup.Count; i++) { DictionaryMocks.cityMock[i].Id = dictionaryStorage.CityAddOrUpdate(DictionaryMocks.cityMock[i]).Result; UserMock.listUsers[i].CityId = (int)DictionaryMocks.cityMock[i].Id; UserMock.listUsers[i].Id = await userStorage.UserAddOrUpdate(UserMock.listUsers[i]); CourseMock.listCourse[i].Id = await courseStorage.CourseAddOrUpdate(CourseMock.listCourse[i]); CourseProgramMock.listCourseProgram[i].CourseId = (int)CourseMock.listCourse[i].Id; CourseProgramMock.listCourseProgram[i].Id = await courseStorage.CourseProgramAddOrUpdate(CourseProgramMock.listCourseProgram[i]); GroupMock.groupMocks[i].CourseProgramId = (int)CourseProgramMock.listCourseProgram[i].Id; GroupMock.groupMocks[i].Id = groupStorage.GroupAddOrUpdate(GroupMock.groupMocks[i]).Result; StudentGroupMock.listStudentGroup[i].UserId = (int)UserMock.listUsers[i].Id; StudentGroupMock.listStudentGroup[i].GroupId = (int)GroupMock.groupMocks[i].Id; StudentGroupMock.listStudentGroup[i].Id = groupStorage.StudentGroupInsert(StudentGroupMock.listStudentGroup[i]).Id; } }