Пример #1
0
        private void OnSelect(string dishName, IDishViewController dishViewController, IIngredientSubject ingredientSubject)
        {
            using (IDishController controller = factory.CreateDishController())
            {
                DataControllerMessage <DishEditDTO> controllerMessage = controller.Get(dishName);
                if (controllerMessage.IsSuccess)
                {
                    UIElement view   = dishViewController.GetEditView(ingredientSubject, controllerMessage.Data);
                    Window    window = WindowFactory.CreateByContentsSize(view);

                    window.Title = String.Format("{0} - {1}", dishName, controllerMessage.Data.CategoryName);

                    dishViewController.DishDeleted += (s, e) =>
                    {
                        if (dishName == e.Data)
                        {
                            window.Close();
                        }
                    };

                    window.Show();
                }
                else
                {
                    MessageBox.Show(controllerMessage.Message);
                }
            }
        }
Пример #2
0
        private void Edit(CoefficientDisplayModel coefficientDisplayModel)
        {
            CoefficientInfoViewModel viewModel = new CoefficientInfoViewModel(coefficientDisplayModel);
            CoefficientInfoControl   control   = new CoefficientInfoControl(viewModel);
            Window window = WindowFactory.CreateByContentsSize(control);

            viewModel.CoefficientEdited += (s, e) =>
            {
                CoefficientEditModel coefficientEditModel = e.Coefficient;
                CoefficientEditDTO   coefficientEditDTO   = Mapper.Map <CoefficientEditModel, CoefficientEditDTO>(coefficientEditModel);

                using (ICoefficientService service = factory.CreateCoefficientService())
                {
                    ServiceMessage serviceMessage = service.Update(coefficientEditDTO);
                    RaiseReceivedMessageEvent(serviceMessage);

                    if (serviceMessage.IsSuccessful)
                    {
                        window.Close();
                        Notify();
                    }
                }
            };

            window.Show();
        }
Пример #3
0
        private void EditCountry(string countryName)
        {
            CountryEditViewModel viewModel = new CountryEditViewModel(countryName);
            CountryEditControl   control   = new CountryEditControl(viewModel);
            Window window = WindowFactory.CreateByContentsSize(control);

            viewModel.CountryEdited += (s, e) =>
            {
                CountryEditModel countryEditModel = e.Country;
                CountryEditDTO   countryEditDTO   = Mapper.Map <CountryEditModel, CountryEditDTO>(countryEditModel);

                using (ICountryService service = factory.CreateCountryService())
                {
                    ServiceMessage serviceMessage = service.Update(countryEditDTO);
                    RaiseReceivedMessageEvent(serviceMessage.IsSuccessful, serviceMessage.Message);

                    if (serviceMessage.IsSuccessful)
                    {
                        window.Close();
                        Notify();
                    }
                }
            };

            window.Show();
        }
Пример #4
0
        private void Edit(BookmakerDisplayModel bookmakerDisplayModel)
        {
            BookmakerEditModel bookmakerEditModel = Mapper.Map <BookmakerDisplayModel, BookmakerEditModel>(bookmakerDisplayModel);

            BookmakerInfoViewModel viewModel = new BookmakerInfoViewModel(bookmakerEditModel);
            BookmakerInfoControl   control   = new BookmakerInfoControl(viewModel);
            Window window = WindowFactory.CreateByContentsSize(control);

            viewModel.BookmakerEdited += (s, e) =>
            {
                bookmakerEditModel = e.Bookmaker;
                BookmakerEditDTO bookmakerEditDTO = Mapper.Map <BookmakerEditModel, BookmakerEditDTO>(bookmakerEditModel);

                using (IBookmakerService service = factory.CreateBookmakerService())
                {
                    ServiceMessage serviceMessage = service.Update(bookmakerEditDTO, bookmakerDisplayModel.Login);
                    RaiseReceivedMessageEvent(serviceMessage.IsSuccessful, serviceMessage.Message);

                    if (serviceMessage.IsSuccessful)
                    {
                        window.Close();
                        Notify();
                    }
                }
            };

            window.Show();
        }
Пример #5
0
        public void Display()
        {
            UIElement element = GetDisplayElement();
            Window    window  = WindowFactory.CreateByContentsSize(element);

            window.Show();
        }
Пример #6
0
        private void Edit(ParticipantDisplayModel participantDisplayModel, IEnumerable <string> countries, IEnumerable <string> sports)
        {
            ParticipantInfoViewModel viewModel = new ParticipantInfoViewModel(participantDisplayModel, sports, countries);
            ParticipantInfoControl   control   = new ParticipantInfoControl(viewModel);
            Window window = WindowFactory.CreateByContentsSize(control);

            viewModel.ParticipantEdited += (s, e) =>
            {
                ParticipantEditModel participantEditModel = e.Participant;
                ParticipantEditDTO   participantEditDTO   = Mapper.Map <ParticipantEditModel, ParticipantEditDTO>(participantEditModel);

                using (IParticipantService service = factory.CreateParticipantService())
                {
                    ServiceMessage serviceMessage = service.Update(participantEditDTO);
                    RaiseReceivedMessageEvent(serviceMessage.IsSuccessful, serviceMessage.Message);

                    if (serviceMessage.IsSuccessful)
                    {
                        window.Close();
                        Notify();
                    }
                }
            };

            window.Show();
        }
Пример #7
0
        public void Register()
        {
            UIElement element = GetRegisterElement();
            Window    window  = WindowFactory.CreateByContentsSize(element);

            window.Show();
        }
Пример #8
0
        public void Add()
        {
            UIElement element = GetAddElement();
            Window    window  = WindowFactory.CreateByContentsSize(element);

            window.Show();
        }
Пример #9
0
        private void Edit(BetDisplayModel betDisplayModel)
        {
            BetInfoViewModel viewModel = new BetInfoViewModel(betDisplayModel);
            BetInfoControl   control   = new BetInfoControl(viewModel);
            Window           window    = WindowFactory.CreateByContentsSize(control);

            viewModel.BetEdited += (s, e) =>
            {
                BetEditModel betEditModel = e.Bet;
                BetEditDTO   betEditDTO   = Mapper.Map <BetEditModel, BetEditDTO>(betEditModel);

                using (IBetService service = factory.CreateBetService())
                {
                    ServiceMessage serviceMessage = service.Update(betEditDTO);
                    RaiseReceivedMessageEvent(serviceMessage);

                    if (serviceMessage.IsSuccessful)
                    {
                        window.Close();
                        Notify();
                    }
                }
            };

            window.Show();
        }
Пример #10
0
        private void EditSport(string sportName)
        {
            SportEditViewModel viewModel = new SportEditViewModel(sportName);
            SportEditControl   control   = new SportEditControl(viewModel);
            Window             window    = WindowFactory.CreateByContentsSize(control);

            viewModel.SportEdited += (s, e) =>
            {
                SportEditModel sportEditModel = e.Sport;
                SportEditDTO   sportEditDTO   = Mapper.Map <SportEditModel, SportEditDTO>(sportEditModel);

                using (ISportService service = factory.CreateSportService())
                {
                    ServiceMessage serviceMessage = service.Update(sportEditDTO);
                    RaiseReceivedMessageEvent(serviceMessage.IsSuccessful, serviceMessage.Message);

                    if (serviceMessage.IsSuccessful)
                    {
                        window.Close();
                        Notify();
                    }
                }
            };

            window.Show();
        }
Пример #11
0
        private void Edit(AnalyticDisplayModel analyticDisplayModel)
        {
            AnalyticEditModel analytic = new AnalyticEditModel
            {
                FirstName   = analyticDisplayModel.FirstName,
                LastName    = analyticDisplayModel.LastName,
                PhoneNumber = analyticDisplayModel.PhoneNumber,
                Login       = analyticDisplayModel.Login
            };

            AnalyticInfoViewModel viewModel = new AnalyticInfoViewModel(analytic);
            AnalyticInfoControl   control   = new AnalyticInfoControl(viewModel);
            Window window = WindowFactory.CreateByContentsSize(control);

            viewModel.AnalyticEdited += (s, e) =>
            {
                AnalyticEditModel analyticEditModel = e.Analytic;
                AnalyticEditDTO   analyticEditDTO   = Mapper.Map <AnalyticEditModel, AnalyticEditDTO>(analyticEditModel);

                using (IAnalyticService service = factory.CreateAnalyticService())
                {
                    ServiceMessage serviceMessage = service.Update(analyticEditDTO);
                    RaiseReceivedMessageEvent(serviceMessage);

                    if (serviceMessage.IsSuccessful)
                    {
                        window.Close();
                        Notify();
                    }
                }
            };

            window.Show();
        }
Пример #12
0
        protected void ShowLogWindow()
        {
            LogControl control = new LogControl(logger);
            Window     window  = WindowFactory.CreateByContentsSize(control);

            window.Show();
        }
Пример #13
0
        public void ChangePassword()
        {
            UIElement element = GetPasswordElement();
            Window    window  = WindowFactory.CreateByContentsSize(element);

            window.ShowDialog();
        }
Пример #14
0
        public UIElement GetListView(IIngredientSubject subject)
        {
            DishListViewModel viewModel = new DishListViewModel(factory, this);
            DishListView      view      = new DishListView(viewModel);
            Window            window    = WindowFactory.CreateByContentsSize(view);

            viewModel.DishSelected += (s, e) => OnSelected(e.Data, subject);

            return(view);
        }
Пример #15
0
        public UIElement GetListView()
        {
            CategoryListViewModel viewModel = new CategoryListViewModel(factory, this);
            CategoryListView      view      = new CategoryListView(viewModel);
            Window window = WindowFactory.CreateByContentsSize(view);

            viewModel.CategorySelected += (s, e) => OnSelect(e.Data);

            return(view);
        }
Пример #16
0
        private void Edit(DishEditDTO dishEditDTO, IIngredientSubject subject)
        {
            IngredientListViewModel ingredientListViewModel = new IngredientListViewModel(factory, subject);
            RecipeAddViewModel      recipeAddViewModel      = new RecipeAddViewModel(factory, this, ingredientListViewModel);

            recipeAddViewModel.MustSelectDish = false;

            DishEditViewModel viewModel = new DishEditViewModel(dishEditDTO, recipeAddViewModel);
            DishEditView      view      = new DishEditView(viewModel);
            Window            window    = WindowFactory.CreateByContentsSize(view);

            window.MinWidth = view.MinWidth;

            viewModel.DishSaveRequest += (s, e) =>
            {
                using (IDishController controller = factory.CreateDishController())
                {
                    ControllerMessage controllerMessage = controller.Update(e.Data);
                    if (controllerMessage.IsSuccess)
                    {
                        Notify();
                    }
                    else
                    {
                        MessageBox.Show(controllerMessage.Message);
                    }
                }
            };
            viewModel.DishSaveRecipesRequest += (s, e) =>
            {
                using (IDishController controller = factory.CreateDishController())
                {
                    ControllerMessage controllerMessage = controller.UpdateRecipes(e.Data);
                    if (controllerMessage.IsSuccess)
                    {
                        Notify();
                    }
                    else
                    {
                        MessageBox.Show(controllerMessage.Message);
                    }
                }
            };

            window.Show();
        }
Пример #17
0
        private void Edit(EventDisplayModel eventDisplayModel, IEnumerable <ParticipantBaseModel> allParticipants)
        {
            EventManageViewModel viewModel = new EventManageViewModel(eventDisplayModel, allParticipants);
            EventManageControl   control   = new EventManageControl(viewModel);
            Window window = WindowFactory.CreateByContentsSize(control);

            viewModel.InfoViewModel.EventEdited += (s, e) =>
            {
                EventEditModel eventEditModel = e.Event;
                EventEditDTO   eventEditDTO   = Mapper.Map <EventEditModel, EventEditDTO>(eventEditModel);

                using (IEventService service = factory.CreateEventService())
                {
                    ServiceMessage serviceMessage = service.Update(eventEditDTO);
                    RaiseReceivedMessageEvent(serviceMessage);

                    if (serviceMessage.IsSuccessful)
                    {
                        Notify();
                    }
                }
            };
            viewModel.EventParticipantViewModel.EventEdited += (s, e) =>
            {
                EventEditModel eventEditModel = e.Event;
                EventEditDTO   eventEditDTO   = Mapper.Map <EventEditModel, EventEditDTO>(eventEditModel);

                using (IEventService service = factory.CreateEventService())
                {
                    ServiceMessage serviceMessage = service.UpdateParticipants(eventEditDTO);
                    RaiseReceivedMessageEvent(serviceMessage);

                    if (serviceMessage.IsSuccessful)
                    {
                        Notify();
                    }
                }
            };

            window.Show();
        }
Пример #18
0
        private void Edit(TournamentBaseModel tournament, IEnumerable <ParticipantBaseModel> tournamentParticipants, IEnumerable <ParticipantBaseModel> sportParticipants)
        {
            TournamentManageViewModel viewModel = new TournamentManageViewModel(tournament, tournamentParticipants, sportParticipants);
            TournamentManageControl   control   = new TournamentManageControl(viewModel);
            Window window = WindowFactory.CreateByContentsSize(control);

            viewModel.InfoViewModel.TournamentEdited += (s, e) =>
            {
                TournamentEditModel tournamentEditModel = e.Tournament;
                TournamentEditDTO   tournamentEditDTO   = Mapper.Map <TournamentEditModel, TournamentEditDTO>(tournamentEditModel);

                using (ITournamentService service = factory.CreateTournamentService())
                {
                    ServiceMessage serviceMessage = service.Update(tournamentEditDTO);
                    RaiseReceivedMessageEvent(serviceMessage.IsSuccessful, serviceMessage.Message);

                    if (serviceMessage.IsSuccessful)
                    {
                        Notify();
                    }
                }
            };
            viewModel.ParticipantViewModel.TournamentEdited += (s, e) =>
            {
                TournamentEditModel tournamentEditModel = e.Tournament;
                TournamentEditDTO   tournamentEditDTO   = Mapper.Map <TournamentEditModel, TournamentEditDTO>(tournamentEditModel);

                using (ITournamentService service = factory.CreateTournamentService())
                {
                    ServiceMessage serviceMessage = service.UpdateParticipants(tournamentEditDTO);
                    RaiseReceivedMessageEvent(serviceMessage.IsSuccessful, serviceMessage.Message);

                    if (serviceMessage.IsSuccessful)
                    {
                        Notify();
                    }
                }
            };

            window.Show();
        }
Пример #19
0
        private void DisplayCategory(CategoryEditDTO categoryEditDTO)
        {
            CategoryEditViewModel viewModel = new CategoryEditViewModel(categoryEditDTO);
            CategoryEditView      view      = new CategoryEditView(viewModel);
            Window window = WindowFactory.CreateByContentsSize(view);

            viewModel.CategorySaveRequest += (s, e) =>
            {
                using (ICategoryController controller = factory.CreateCategoryController())
                {
                    ControllerMessage controllerMessage = controller.Update(e.Data);
                    if (controllerMessage.IsSuccess)
                    {
                        Notify();
                    }
                    else
                    {
                        MessageBox.Show(controllerMessage.Message);
                    }
                }
            };

            window.Show();
        }