private static CategorySettings SanitizedSettings(CategorySettings categorySetting)
        {
            var fromRepo = LibraryApp.App.Context.GetRepository<CategorySettings>().GetOneByQuery(
                c => StaticHelper.StringsEqual(c.Category, categorySetting.Category)
                );

            return fromRepo ?? categorySetting;
        }
 public void CreateCategory(object sender, EventArgs args)
 {
     AddCategoryView view = (AddCategoryView) sender;
     CategorySettings categorySetting = new CategorySettings();
     categorySetting.BorrowTime = view.borrow;
     categorySetting.ReservationTime = view.reservation;
     categorySetting.FinePerTardinessDay = view.fine;
     categorySetting.Category = view.name;
     _settingsRepository.Save(categorySetting);
 }
 public static Book CreateBook(Dictionary<string, object> bookPropertiesMap, ICollection<Author> authors, ICollection<Tag> tags, CategorySettings categorySetting)
 {
     return new Book()
     {
         Title = (string) bookPropertiesMap["title"],
         Authors = SanitizedAuthors(authors),
         CategorySetting = SanitizedSettings(categorySetting),
         Tags = SanitizedTags(tags)
     };
 }
        public static void DummyBooksAndStuff(Context context)
        {
            var settings0 = new CategorySettings()
            {
                Category = "Important",
                BorrowTime = 1,
                EffectiveFrom = new DateTime(),
                FinePerTardinessDay = 1.05,
                ReservationTime = 2
            };

            context.GetRepository<CategorySettings>().Save(settings0);

            var settings1 = new CategorySettings()
            {
                Category = "LessImportant",
                BorrowTime = 1,
                EffectiveFrom = new DateTime(),
                FinePerTardinessDay = 1.0,
                ReservationTime = 2
            };

            var tags0 = new List<Tag>() {new Tag(){Name="fantasy"}, new Tag(){Name="przygodowa"}};
            var tags1 = new List<Tag>() {new Tag(){Name="przygodowa"}, new Tag(){Name="horror"}};

            var authors0 = new List<Author>() {new Author("J. R. R.", "Tolkien")};
            var authors1 = new List<Author>() {new Author("J. R. R.", "Tolkien"), new Author("some", "othoer")};

            var map0 = new Dictionary<string, object>()
            {
                {"title", "title0"}
            };

            var map1 = new Dictionary<string, object>()
            {
                {"title", "title1"}
            };

            var book0 = BookFactory.CreateBook(map0, authors0, tags0, settings0);
            context.GetRepository<Book>().Save(book0);

            var book1 = BookFactory.CreateBook(map1, authors1, tags1, settings1);
            context.GetRepository<Book>().Save(book1);
        }
 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         string category = comboBox1.SelectedItem.ToString();
         CategorySettings categorySetting = findSettingForCategory(category);
         fineTextBox.Text = categorySetting.FinePerTardinessDay + "";
         daysTextBox.Text = categorySetting.BorrowTime + "";
         reservationTextBox.Text = categorySetting.ReservationTime + "";
         this.categorySetting = categorySetting;
     }
     catch (Exception ex)
     {
     }
 }