예제 #1
0
        protected override object GetUpdateDialogView()
        {
            if (ViewModel is PriplodsViewModel viewModel && viewModel.SelectedModel != null)
            {
                var snackbar = (Application.Current.MainWindow as MainWindow)?.MainSnackbar.MessageQueue;
                var user     = (Application.Current.MainWindow as MainWindow)?.ViewModel.User;

                if (snackbar == null || user == null)
                {
                    return(null);
                }

                var cowsVm     = new CowsViewModel(snackbar, viewModel.CowsViewModel.Models, user, viewModel.CowsViewModel.BullsViewModel, viewModel.CowsViewModel.BloodTypesViewModel, viewModel.CowsViewModel.CategoriesViewModel, viewModel.CowsViewModel.LinesViewModel, viewModel.CowsViewModel.BreedsViewModel, viewModel.CowsViewModel.FamiliesViewModel);
                var priplodsVm = new PriplodsViewModel(snackbar, user, cowsVm, viewModel.GendersViewModel, viewModel.Models);

                var priplodVm = new PriplodViewModel()
                {
                    Id       = viewModel.SelectedModel.Id,
                    CowId    = viewModel.SelectedModel.CowId,
                    GenderId = viewModel.SelectedModel.GenderId,
                    Weight   = viewModel.SelectedModel.Weight,
                    Gender   = viewModel.SelectedModel.Gender,
                    Mother   = viewModel.SelectedModel.Mother
                };

                return(new PriplodDialog("Изменить", priplodVm, priplodsVm));
            }

            return(null);
        }
예제 #2
0
        protected override object GetUpdateDialogView()
        {
            if (ViewModel is RetirementsViewModel viewModel && viewModel.SelectedModel != null)
            {
                var snackbar = (Application.Current.MainWindow as MainWindow)?.MainSnackbar.MessageQueue;
                var user     = (Application.Current.MainWindow as MainWindow)?.ViewModel.User;

                if (snackbar == null || user == null)
                {
                    return(null);
                }

                var cowsVm = new CowsViewModel(snackbar, viewModel.CowsViewModel.Models, user, viewModel.CowsViewModel.BullsViewModel, viewModel.CowsViewModel.BloodTypesViewModel, viewModel.CowsViewModel.CategoriesViewModel, viewModel.CowsViewModel.LinesViewModel, viewModel.CowsViewModel.BreedsViewModel, viewModel.CowsViewModel.FamiliesViewModel);
                var retVm  = new RetirementsViewModel(snackbar, user, cowsVm, viewModel.Models);

                var retirementVm = new RetirementViewModel()
                {
                    Id     = viewModel.SelectedModel.Id,
                    CowId  = viewModel.SelectedModel.CowId,
                    Date   = viewModel.SelectedModel.Date,
                    Reason = viewModel.SelectedModel.Reason,
                    Cow    = viewModel.SelectedModel.Cow
                };

                return(new RetirementDialog("Изменить", retirementVm, retVm));
            }

            return(null);
        }
예제 #3
0
        protected override object GetUpdateDialogView()
        {
            if (ViewModel is ProductivitiesViewModel viewModel && viewModel.SelectedModel != null)
            {
                var snackbar = (Application.Current.MainWindow as MainWindow)?.MainSnackbar.MessageQueue;
                var user     = (Application.Current.MainWindow as MainWindow)?.ViewModel.User;

                if (snackbar == null || user == null)
                {
                    return(null);
                }

                var cowsVm  = new CowsViewModel(snackbar, viewModel.CowsViewModel.Models, user, viewModel.CowsViewModel.BullsViewModel, viewModel.CowsViewModel.BloodTypesViewModel, viewModel.CowsViewModel.CategoriesViewModel, viewModel.CowsViewModel.LinesViewModel, viewModel.CowsViewModel.BreedsViewModel, viewModel.CowsViewModel.FamiliesViewModel);
                var prodsVm = new ProductivitiesViewModel(snackbar, user, cowsVm, viewModel.Models);

                var productivityVm = new ProductivityViewModel()
                {
                    Id              = viewModel.SelectedModel.Id,
                    BelokProz       = viewModel.SelectedModel.BelokProz,
                    Date            = viewModel.SelectedModel.Date,
                    Cow             = viewModel.SelectedModel.Cow,
                    CowId           = viewModel.SelectedModel.CowId,
                    UchtenoLaktacij = viewModel.SelectedModel.UchtenoLaktacij,
                    UdojKg          = viewModel.SelectedModel.UdojKg,
                    ZhirProz        = viewModel.SelectedModel.ZhirProz
                };

                return(new ProductivityDialog("Изменить", productivityVm, prodsVm));
            }

            return(null);
        }
예제 #4
0
        public ActionResult Create()
        {
            var model = new CowsViewModel();

            model.StateSelectList = selectList;
            model.BirthDate       = DateTime.Today;
            return(View(model));
        }
예제 #5
0
 public ActionResult Create(CowsViewModel model)
 {
     model.StateSelectList = selectList;
     if (ModelState.IsValid)
     {
         Cattle cow = mapper.Map <Cattle>(model);
         cow.CattleTypeId = (int)CattleTypes.Cow;
         cow.Sex          = (int)Sex.Female;
         db.Repository.Add(cow);
         db.Commit();
         return(RedirectToAction("Index", "Cows"));
     }
     return(View(model));
 }
예제 #6
0
 public ActionResult Edit(int id, CowsViewModel model)
 {
     model.StateSelectList = selectList;
     if (ModelState.IsValid)
     {
         Cattle cow = mapper.Map <Cattle>(model);
         cow.Id           = id;
         cow.CattleTypeId = (int)CattleTypes.Cow;
         db.Repository.Update(cow);
         db.Commit();
         return(RedirectToAction("Index", "Cows"));
     }
     return(View(model));
 }
예제 #7
0
        public CowDialog(string action, CowViewModel viewModel, CowsViewModel cowsVm)
        {
            ViewModel = viewModel;

            InitializeComponent();

            PART_inputMother.DataContext     = cowsVm;
            PART_inputFather.DataContext     = cowsVm.BullsViewModel;
            PART_selectBloodType.DataContext = cowsVm.BloodTypesViewModel;
            PART_selectBreed.DataContext     = cowsVm.BreedsViewModel;
            PART_selectCategory.DataContext  = cowsVm.CategoriesViewModel;
            PART_selectFamily.DataContext    = cowsVm.FamiliesViewModel;
            PART_selectLine.DataContext      = cowsVm.LinesViewModel;

            ActionTb.Text = action.ToUpper();
        }
예제 #8
0
        protected override object GetUpdateDialogView()
        {
            if (ViewModel is CowsViewModel viewModel && viewModel.SelectedModel != null)
            {
                var cowVm = new CowViewModel()
                {
                    Id          = viewModel.SelectedModel.Id,
                    BreedId     = viewModel.SelectedModel.BreedId,
                    LineId      = viewModel.SelectedModel.LineId,
                    FamilyId    = viewModel.SelectedModel.FamilyId,
                    CategoryId  = viewModel.SelectedModel.CategoryId,
                    BloodTypeId = viewModel.SelectedModel.BloodTypeId,
                    MotherId    = viewModel.SelectedModel.MotherId,
                    FatherId    = viewModel.SelectedModel.FatherId,
                    Porodnost   = viewModel.SelectedModel.Porodnost.Value,
                    Name        = viewModel.SelectedModel.Name,
                    BDay        = viewModel.SelectedModel.BDay.Value,
                    BPlace      = viewModel.SelectedModel.BPlace,
                    Weight      = viewModel.SelectedModel.Weight.Value,
                    Age         = viewModel.SelectedModel.Age.Value,
                    IsInHerd    = viewModel.SelectedModel.IsInHerd.Value,
                    Breed       = viewModel.SelectedModel.Breed,
                    Line        = viewModel.SelectedModel.Line,
                    Family      = viewModel.SelectedModel.Family,
                    Category    = viewModel.SelectedModel.Category,
                    BloodType   = viewModel.SelectedModel.BloodType,
                    Mother      = viewModel.SelectedModel.Mother,
                    Father      = viewModel.SelectedModel.Father
                };

                var snackbar = (Application.Current.MainWindow as MainWindow)?.MainSnackbar.MessageQueue;
                var user     = (Application.Current.MainWindow as MainWindow)?.ViewModel.User;

                if (snackbar == null || user == null)
                {
                    return(null);
                }

                var bullsVm = new BullsViewModel(snackbar, user, viewModel.BullsViewModel.Models);
                var cowsVm  = new CowsViewModel(snackbar, viewModel.Models, user, bullsVm, viewModel.BloodTypesViewModel, viewModel.CategoriesViewModel, viewModel.LinesViewModel, viewModel.BreedsViewModel, viewModel.FamiliesViewModel);

                return(new CowDialog("Изменить", cowVm, cowsVm));
            }

            return(null);
        }
예제 #9
0
        public CowsView(CowsViewModel viewModel)
            : base(viewModel)
        {
            InitializeComponent();

            ActionItems.Add(new ActionItem("Фильтр", PackIconKind.Filter, PackIconKind.FilterOutline, new RelayCommand(sender =>
            {
                if (sender is ActionItem item)
                {
                    UpdateContent(item, new CowsFilterView()
                    {
                        DataContext = ViewModel
                    });
                }
            })));

            ActionItems.Add(new CommandItem("Сохранить", PackIconKind.Download, viewModel.SaveAsCommand));
        }
예제 #10
0
        protected override object GetAddDialogView()
        {
            if (ViewModel is PriplodsViewModel viewModel)
            {
                var snackbar = (Application.Current.MainWindow as MainWindow)?.MainSnackbar.MessageQueue;
                var user     = (Application.Current.MainWindow as MainWindow)?.ViewModel.User;

                if (snackbar == null || user == null)
                {
                    return(null);
                }

                var cowsVm     = new CowsViewModel(snackbar, viewModel.CowsViewModel.Models, user, viewModel.CowsViewModel.BullsViewModel, viewModel.CowsViewModel.BloodTypesViewModel, viewModel.CowsViewModel.CategoriesViewModel, viewModel.CowsViewModel.LinesViewModel, viewModel.CowsViewModel.BreedsViewModel, viewModel.CowsViewModel.FamiliesViewModel);
                var priplodsVm = new PriplodsViewModel(snackbar, user, cowsVm, viewModel.GendersViewModel, viewModel.Models);

                return(new PriplodDialog("Добавить", new PriplodViewModel(), priplodsVm));
            }

            return(null);
        }
예제 #11
0
        protected override object GetUpdateDialogView()
        {
            if (ViewModel is ReproductionsViewModel viewModel && viewModel.SelectedModel != null)
            {
                var snackbar = (Application.Current.MainWindow as MainWindow)?.MainSnackbar.MessageQueue;
                var user     = (Application.Current.MainWindow as MainWindow)?.ViewModel.User;

                if (snackbar == null || user == null)
                {
                    return(null);
                }

                var bullsVm = new BullsViewModel(snackbar, user, viewModel.CowsViewModel.BullsViewModel.Models);
                var cowsVm  = new CowsViewModel(snackbar, viewModel.CowsViewModel.Models, user, bullsVm, viewModel.CowsViewModel.BloodTypesViewModel, viewModel.CowsViewModel.CategoriesViewModel, viewModel.CowsViewModel.LinesViewModel, viewModel.CowsViewModel.BreedsViewModel, viewModel.CowsViewModel.FamiliesViewModel);
                var reprsVm = new ReproductionsViewModel(snackbar, user, cowsVm, viewModel.MethodsSluchkiViewModel, viewModel.Models);

                var repVm = new ReproductionViewModel()
                {
                    Id              = viewModel.SelectedModel.Id,
                    CowId           = viewModel.SelectedModel.CowId,
                    MethodSluchkiId = viewModel.SelectedModel.MethodSluchkiId,
                    BullId          = viewModel.SelectedModel.BullId,
                    DateOsemeneniya = viewModel.SelectedModel.DateOsemeneniya,
                    ChisloSuhihDney = viewModel.SelectedModel.ChisloSuhihDney,
                    SerPeriod       = viewModel.SelectedModel.SerPeriod,
                    DateOtela       = viewModel.SelectedModel.DateOtela,
                    Bull            = viewModel.SelectedModel.Bull,
                    Cow             = viewModel.SelectedModel.Cow,
                    MethodSluchki   = viewModel.SelectedModel.MethodSluchki
                };

                return(new ReproductionDialog("Изменить", repVm, reprsVm));
            }

            return(null);
        }
예제 #12
0
        public MainViewModel(User user, INavigation navigation, string title, ISnackbarMessageQueue snackbarMessageQueue)
            : base(navigation, title, snackbarMessageQueue)
        {
            _user = user ?? throw new ArgumentNullException(nameof(user));

            var homeVm = new HomeViewModel(snackbarMessageQueue);

            Navigation.Add(() => new Home(homeVm));

            var bloodyVm = new BloodTypesViewModel(snackbarMessageQueue, _user);

            Navigation.Add(() => new BloodTypesView(bloodyVm));

            var breedsVm = new BreedsViewModel(snackbarMessageQueue, _user);

            Navigation.Add(() => new BreedsView(breedsVm));

            var categoriesVm = new CategoriesViewModel(snackbarMessageQueue, _user);

            Navigation.Add(() => new CategoriesView(categoriesVm));

            var linesVm = new LinesViewModel(snackbarMessageQueue, _user);

            Navigation.Add(() => new LinesView(linesVm));

            var familiesVm = new FamiliesViewModel(snackbarMessageQueue, _user);

            Navigation.Add(() => new FamiliesView(familiesVm));

            var gendersVm = new GendersViewModel(snackbarMessageQueue, _user);

            Navigation.Add(() => new GendersView(gendersVm));

            var msVm = new MethodsSluchkiViewModel(snackbarMessageQueue, _user);

            Navigation.Add(() => new MethodsSluchkiView(msVm));

            var bullsVm = new BullsViewModel(snackbarMessageQueue, _user);

            Navigation.Add(() => new BullsView(bullsVm));

            var cowsVm = new CowsViewModel(snackbarMessageQueue, _user, bullsVm, bloodyVm, categoriesVm, linesVm, breedsVm, familiesVm);

            Navigation.Add(() => new CowsView(cowsVm));

            var repsVm = new ReproductionsViewModel(snackbarMessageQueue, _user, cowsVm, msVm);

            Navigation.Add(() => new ReproductionsView(repsVm));

            var usersTypesVm = new UsersTypesViewModel(snackbarMessageQueue, _user);

            var usersVm = new UsersViewModel(snackbarMessageQueue, _user, usersTypesVm);

            Navigation.Add(() => new UsersView(usersVm));

            var prodVm = new ProductivitiesViewModel(snackbarMessageQueue, _user, cowsVm);

            Navigation.Add(() => new ProductivitiesView(prodVm));

            var retVm = new RetirementsViewModel(snackbarMessageQueue, _user, cowsVm);

            Navigation.Add(() => new RetirementsView(retVm));

            var priplodsVm = new PriplodsViewModel(snackbarMessageQueue, _user, cowsVm, gendersVm);

            Navigation.Add(() => new PriplodsView(priplodsVm));

            _pagesViewModels = new IPageViewModel[]
            {
                homeVm, bloodyVm, breedsVm, categoriesVm, linesVm, familiesVm, gendersVm, msVm, bullsVm, prodVm, cowsVm, usersTypesVm, usersVm, retVm, priplodsVm
            };

            Navigation.Navigating += (obj, e) =>
            {
                if (e.Content != null && e.Content.DataContext is IDatabaseTableViewModel dbVm)
                {
                    dbVm.ClearData();
                }
            };

            _navigationItems = new INavigationItem[]
            {
                new NavigationItem(bloodyVm.Title, typeof(BloodTypesView), PackIconKind.Fire),
                new NavigationItem(breedsVm.Title, typeof(BreedsView), PackIconKind.Eraser),
                new NavigationItem(categoriesVm.Title, typeof(CategoriesView), PackIconKind.CardsOutline),
                new NavigationItem(linesVm.Title, typeof(LinesView), PackIconKind.SourceBranch),
                new NavigationItem(familiesVm.Title, typeof(FamiliesView), PackIconKind.CardsVariant),
                new NavigationItem(gendersVm.Title, typeof(GendersView), PackIconKind.GenderMaleFemale),
                new NavigationItem(msVm.Title, typeof(MethodsSluchkiView), PackIconKind.SourceFork),
                new NavigationItem(bullsVm.Title, typeof(BullsView), PackIconKind.Cow),
                new NavigationItem(prodVm.Title, typeof(ProductivitiesView), PackIconKind.ChartBar),
                new NavigationItem(usersVm.Title, typeof(UsersView), PackIconKind.AccountMultiple),
                new NavigationItem(cowsVm.Title, typeof(CowsView), PackIconKind.Cow),
                new NavigationItem(repsVm.Title, typeof(ReproductionsView), PackIconKind.HeartHalfFull),
                new NavigationItem(retVm.Title, typeof(RetirementsView), PackIconKind.Logout),
                new NavigationItem(priplodsVm.Title, typeof(PriplodsView), PackIconKind.Cow)
            }.OrderBy(i => i.Title).Prepend(new NavigationItem(homeVm.Title, typeof(Home), PackIconKind.Home));

            Links = new ILink[]
            {
                new Link("GitHub", "https://github.com/holydk/Farming", PackIconKind.GithubCircle, "Исходный код")
            };
        }