public DictPage()
        {
            InitializeComponent();


            BindingContext = viewModel = new DictViewModel();
        }
示例#2
0
        public ActionResult New(string id)
        {
            var mdoel = new DictViewModel
            {
                IndexID = id,
            };

            return(View(mdoel));
        }
示例#3
0
        public ActionResult Edit(DictViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var result = _dictService.Update(model);

            return(RedirectToAction("Index", "Result", new { state = result, style = "dialog" }));
        }
示例#4
0
        /// <summary>
        /// Responds to click event in the context menu of the dataGrid with dictionaries.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DictContextMenu_ClickDelete(object sender, RoutedEventArgs e)
        {
            DictViewModel item = dictsGrid.SelectedItem as DictViewModel;

            if (item != null)
            {
                // Let the view model delete the dicionary.
                item.DeleteFile();
            }
        }
示例#5
0
        public bool Update(DictViewModel model)
        {
            var entity = uow.Set <Dict>().Find(model.Id);

            if (entity == null)
            {
                return(false);
            }
            entity.No          = model.No;
            entity.Key         = model.Key;
            entity.Value       = model.Value;
            entity.Description = model.Description;
            entity.Index       = uow.Set <DictIndex>().Find(model.IndexID);
            uow.Commit();
            return(true);
        }
示例#6
0
        public bool Add(DictViewModel model)
        {
            model.Id = Guid.NewGuid().ToString();
            Dict entity = new Dict();

            uow.Set <Dict>().Add(entity);
            entity.Id          = model.Id;
            entity.No          = model.No;
            entity.Key         = model.Key;
            entity.Value       = model.Value;
            entity.Description = model.Description;

            entity.Index = uow.Set <DictIndex>().Find(model.IndexID);
            uow.Commit();
            return(true);
        }
示例#7
0
        public ActionResult Delete(DictViewModel model)
        {
            var result = _dictService.Delete(model.Id);

            return(RedirectToAction("Index", "Result", new { state = result, style = "dialog" }));
        }
示例#8
0
        public static ServicesSoapClient _ServicesSoapClient = new ServicesSoapClient();//WebService

        //字典选择
        public ActionResult Index()
        {
            DictViewModel dict = new DictViewModel();

            return(View(dict));
        }
示例#9
0
        public EditProfileViewModel CreateEditProfileViewModel(Guid userId)
        {
            User user = _userService.FindById(userId);

            if (user == null)
            {
                throw new ArgumentException("User not exist!");
            }

            var editProfileViewModel = new EditProfileViewModel {
                FirstName        = user.FirstName,
                LastName         = user.LastName,
                Motto            = user.Motto,
                Location         = user.Location,
                WebAddress       = user.WebAddress,
                Language         = user.Language.Id,
                CoverPatternName = user.CoverPatternName
            };

            if (user.CoverFile != null)
            {
                editProfileViewModel.CoverImageUrl = _fileService.GetUrlToFileThumbnail(user.CoverFile);
            }

            IList <CategoryFavouriteLevel> levels = _categoryFavouriteLevelService.FindAll().OrderBy(x => x.FavouriteLevel).ToList();

            foreach (var level in levels)
            {
                var categoryViewModel = new CategoryViewModel {
                    LevelId        = level.Id,
                    LevelName      = level.Name,
                    FavouriteLevel = level.FavouriteLevel
                };

                IList <Guid> userCategory = user.UserCategories.Where(x => x.CategoryFavouriteLevel.Id == level.Id).Select(x => x.Category.Id).ToList();
                categoryViewModel.SelectedCatagories.AddRange(userCategory);

                editProfileViewModel.CategoryViewModels.Add(categoryViewModel);
            }

            foreach (var language in user.UserMessageLanguages)
            {
                var languageViewModel = new DictViewModel <Guid> {
                    Id   = language.Id,
                    Name = language.Name
                };

                editProfileViewModel.UserMessageLanguages.Add(languageViewModel);
            }

            for (int i = 1; i <= _settingsService.MaxCoverNameCounter; i++)
            {
                string coverId   = string.Format("p{0:00000}.png", i);
                string coverName = string.Format("Template {0:00000}", i);
                editProfileViewModel.CoverPatternNames.Add(new DictViewModel <string>(coverId, coverName));
            }

            editProfileViewModel.Languages.AddRange(_languageService.FindAll());
            editProfileViewModel.Categories.AddRange(_categoryService.FindAll());
            return(editProfileViewModel);
        }