Пример #1
0
        public UIElement GetAddElement()
        {
            SportCreateViewModel viewModel = new SportCreateViewModel();
            SportCreateControl   control   = new SportCreateControl(viewModel);

            viewModel.SportCreated += (s, e) =>
            {
                SportCreateModel sportCreateModel = e.Sport;
                SportCreateDTO   sportCreateDTO   = Mapper.Map <SportCreateModel, SportCreateDTO>(sportCreateModel);

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

                    if (serviceMessage.IsSuccessful)
                    {
                        viewModel.SportName = String.Empty;
                        Notify();
                    }
                }
            };

            return(control);
        }
 public SportCreateControl(SportCreateViewModel viewModel)
 {
     InitializeComponent();
     this.DataContext = viewModel;
 }