public void GetPeriod() { foreach (Period period in GetSomePeriods()) { Assert.AreEqual(period, PeriodManager.GetPeriod(period.Id)); } }
public void GetTaxaByQuery() { Data.ArtDatabankenService.Factor factor; Data.ArtDatabankenService.FactorField factorField; SpeciesFactCondition speciesFactCondition; SpeciesFactFieldCondition speciesFactFieldCondition; TaxonInformationType taxonInformationType; Data.ArtDatabankenService.TaxonList taxa; taxonInformationType = TaxonInformationType.Basic; // Test one factor. speciesFactCondition = new SpeciesFactCondition(); speciesFactCondition.Factors.Add(FactorManagerTest.GetOneFactor()); taxa = Data.ArtDatabankenService.TaxonManager.GetTaxaByQuery(speciesFactCondition, taxonInformationType); Assert.IsTrue(taxa.IsNotEmpty()); // Test several factors. speciesFactCondition = new SpeciesFactCondition(); speciesFactCondition.Factors.AddRange(FactorManagerTest.GetSomeFactors()); taxa = Data.ArtDatabankenService.TaxonManager.GetTaxaByQuery(speciesFactCondition, taxonInformationType); Assert.IsTrue(taxa.IsNotEmpty()); // Test one period. speciesFactCondition = new SpeciesFactCondition(); speciesFactCondition.Factors.Add(Data.ArtDatabankenService.FactorManager.GetFactor(Data.ArtDatabankenService.FactorId.RedlistCategory)); speciesFactCondition.Periods.Add(PeriodManager.GetPeriod(PeriodId.Year2005)); taxa = Data.ArtDatabankenService.TaxonManager.GetTaxaByQuery(speciesFactCondition, taxonInformationType); Assert.IsTrue(taxa.IsNotEmpty()); // Test several periods. speciesFactCondition = new SpeciesFactCondition(); speciesFactCondition.Factors.Add(Data.ArtDatabankenService.FactorManager.GetFactor(Data.ArtDatabankenService.FactorId.RedlistCategory)); speciesFactCondition.Periods.AddRange(PeriodManager.GetPeriods()); taxa = Data.ArtDatabankenService.TaxonManager.GetTaxaByQuery(speciesFactCondition, taxonInformationType); Assert.IsTrue(taxa.IsNotEmpty()); // Test one species fact field enum (KeyInt) condition. speciesFactCondition = new SpeciesFactCondition(); factor = Data.ArtDatabankenService.FactorManager.GetFactor(Data.ArtDatabankenService.FactorId.Redlist_OrganismLabel1); Assert.IsTrue(taxa.IsNotEmpty()); speciesFactCondition.Factors.Add(factor); speciesFactFieldCondition = new SpeciesFactFieldCondition(); factorField = factor.FactorDataType.MainField; speciesFactFieldCondition.FactorField = factorField; speciesFactFieldCondition.SetValue(factorField.FactorFieldEnum.Values[3].KeyInt); speciesFactCondition.SpeciesFactFieldConditions.Add(speciesFactFieldCondition); taxa = Data.ArtDatabankenService.TaxonManager.GetTaxaByQuery(speciesFactCondition, taxonInformationType); Assert.IsTrue(taxa.IsNotEmpty()); // Test several species fact field enum (KeyInt) conditions. speciesFactCondition = new SpeciesFactCondition(); factor = Data.ArtDatabankenService.FactorManager.GetFactor(Data.ArtDatabankenService.FactorId.Redlist_OrganismLabel1); Assert.IsTrue(taxa.IsNotEmpty()); speciesFactCondition.Factors.Add(factor); speciesFactFieldCondition = new SpeciesFactFieldCondition(); factorField = factor.FactorDataType.MainField; speciesFactFieldCondition.FactorField = factorField; speciesFactFieldCondition.SetValue(factorField.FactorFieldEnum.Values[3].KeyInt); speciesFactCondition.SpeciesFactFieldConditions.Add(speciesFactFieldCondition); speciesFactFieldCondition = new SpeciesFactFieldCondition(); factorField = factor.FactorDataType.MainField; speciesFactFieldCondition.FactorField = factorField; speciesFactFieldCondition.SetValue(factorField.FactorFieldEnum.Values[4].KeyInt); speciesFactCondition.SpeciesFactFieldConditions.Add(speciesFactFieldCondition); speciesFactFieldCondition = new SpeciesFactFieldCondition(); factorField = factor.FactorDataType.MainField; speciesFactFieldCondition.FactorField = factorField; speciesFactFieldCondition.SetValue(factorField.FactorFieldEnum.Values[5].KeyInt); speciesFactCondition.SpeciesFactFieldConditions.Add(speciesFactFieldCondition); taxa = ArtDatabanken.Data.ArtDatabankenService.TaxonManager.GetTaxaByQuery(speciesFactCondition, taxonInformationType); Assert.IsTrue(taxa.IsNotEmpty()); // Test one species fact field enum (KeyText) condition. speciesFactCondition = new SpeciesFactCondition(); factor = Data.ArtDatabankenService.FactorManager.GetFactor(Data.ArtDatabankenService.FactorId.Redlist_TaxonType); Assert.IsTrue(taxa.IsNotEmpty()); speciesFactCondition.Factors.Add(factor); speciesFactCondition.Periods.Add(PeriodManager.GetPeriod(2)); speciesFactFieldCondition = new SpeciesFactFieldCondition(); factorField = factor.FactorDataType.MainField; speciesFactFieldCondition.FactorField = factorField; speciesFactFieldCondition.SetValue(factorField.FactorFieldEnum.Values[0].KeyText); speciesFactFieldCondition.IsEnumAsString = true; speciesFactCondition.SpeciesFactFieldConditions.Add(speciesFactFieldCondition); taxa = Data.ArtDatabankenService.TaxonManager.GetTaxaByQuery(speciesFactCondition, taxonInformationType); Assert.IsTrue(taxa.IsNotEmpty()); // Test several species fact field enum (KeyText) condition. speciesFactCondition = new SpeciesFactCondition(); factor = Data.ArtDatabankenService.FactorManager.GetFactor(Data.ArtDatabankenService.FactorId.Redlist_TaxonType); Assert.IsTrue(taxa.IsNotEmpty()); speciesFactCondition.Factors.Add(factor); speciesFactCondition.Periods.Add(PeriodManager.GetPeriod(2)); speciesFactFieldCondition = new SpeciesFactFieldCondition(); factorField = factor.FactorDataType.MainField; speciesFactFieldCondition.FactorField = factorField; speciesFactFieldCondition.SetValue(factorField.FactorFieldEnum.Values[0].KeyText); speciesFactFieldCondition.IsEnumAsString = true; speciesFactCondition.SpeciesFactFieldConditions.Add(speciesFactFieldCondition); speciesFactFieldCondition = new SpeciesFactFieldCondition(); factorField = factor.FactorDataType.MainField; speciesFactFieldCondition.FactorField = factorField; speciesFactFieldCondition.SetValue(factorField.FactorFieldEnum.Values[1].KeyText); speciesFactFieldCondition.IsEnumAsString = true; speciesFactCondition.SpeciesFactFieldConditions.Add(speciesFactFieldCondition); speciesFactFieldCondition = new SpeciesFactFieldCondition(); factorField = factor.FactorDataType.MainField; speciesFactFieldCondition.FactorField = factorField; speciesFactFieldCondition.SetValue(factorField.FactorFieldEnum.Values[2].KeyText); speciesFactFieldCondition.IsEnumAsString = true; speciesFactCondition.SpeciesFactFieldConditions.Add(speciesFactFieldCondition); taxa = Data.ArtDatabankenService.TaxonManager.GetTaxaByQuery(speciesFactCondition, taxonInformationType); Assert.IsTrue(taxa.IsNotEmpty()); }
public TransactionObject AddLesson(AddLessonFormData alFormData) { TransactionObject response = new TransactionObject(); try { Education education = educationManager.GetEducation(alFormData.StudentID, alFormData.LessonID); Student selectedStudent = studentManager.GetStudent(alFormData.StudentID); Lesson selectedLesson = lessonManager.GetLesson(alFormData.LessonID); if (education != null) { Period currentPeriod = periodManager.GetPeriod(selectedLesson.Period.Year, selectedLesson.Period.Semester); Note note = new Note { ResultPoint = alFormData.Result, Description = alFormData.Description, EffectRate = alFormData.Effect, Education = education }; note.Education = education; education.Notes.Add(note); noteManager.AddNote(note); } else { education = new Education(); education.Student = selectedStudent; selectedStudent.Educations.Add(education); education.Lesson = selectedLesson; selectedLesson.Educations.Add(education); Note note = new Note { ResultPoint = alFormData.Result, Description = alFormData.Description, EffectRate = alFormData.Effect, Education = education }; education.Notes.Add(note); note.Education = education; noteManager.AddNote(note); educationManager.AddEducation(education); } double avg = 0; education.Notes.ForEach(note => avg += (note.EffectRate / 100) * note.ResultPoint); education.Average = avg; uow.Save(); response.IsSuccess = true; } catch (Exception ex) { response.IsSuccess = false; response.Explanation = base.GetExceptionMessage(ex); } return(response); }
public TransactionObject CreateAccount(CreateAccountFormData newAccountInfo) { TransactionObject response = new TransactionObject(); if (userManager.IsUserExists(newAccountInfo.Username)) { try { Period period = prdManager.GetPeriod(newAccountInfo.Year, newAccountInfo.Term); User newUser = new User(); Student newStudent = new Student(); newUser.Username = newAccountInfo.Username; newUser.CreationDate = DateTime.Now; newUser.Password = SecurityFolder.Security.GetEncryptedPassword(newAccountInfo.Password);//şifre hashlendi newUser.ProfilePhoto = newAccountInfo.ProfilePhoto; newUser.Email = newAccountInfo.Email; newStudent.Name = newAccountInfo.Name; newStudent.Surname = newAccountInfo.Surname; newStudent.Birthday = new DateTime(1996, 1, 1); newStudent.Period = period; period.Students.Add(newStudent); newUser.Student = newStudent; newStudent.User = newUser; userManager.AddUser(newUser); stdManager.AddStudent(newStudent); FriendRelationship fr = new FriendRelationship(); newUser.FriendRelationship = fr; frManager.AddFriendRelationship(fr); var saveResponse = uow.Save(); if (saveResponse.IsSuccess) { response.IsSuccess = true; } else { response.IsSuccess = false; response.Explanation = saveResponse.Explanation; } } catch (Exception ex) { response.IsSuccess = false; response.Explanation = base.GetExceptionMessage(ex); } } else { response.IsSuccess = false; response.Explanation = "This username is exists! Please try valid username..."; } return(response); }