Exemple #1
0
        public ActionResult Add(ViewModels.BookCategory category)
        {
            ResolveService <IBookCategoryService>().Add(category.CopyToDomainModel());

            return(Json(new JsonResultData {
                Success = true
            }));
        }
Exemple #2
0
        public static DomainModels.BookCategory CopyToDomainModel(this ViewModels.BookCategory viewModel, DomainModels.BookCategory domainModel = null)
        {
            if (domainModel == null)
            {
                domainModel = new DomainModels.BookCategory();
            }

            domainModel.ID     = viewModel.ID;
            domainModel.Name   = viewModel.Name;
            domainModel.Parent = ContainerManager.Current.Resolve <IBookCategoryService>().GetByID(viewModel.ParentID);

            return(domainModel);
        }
Exemple #3
0
        public static ViewModels.BookCategory CopyToViewModel(this DomainModels.BookCategory domainModel, ViewModels.BookCategory viewModel = null)
        {
            if (viewModel == null)
            {
                viewModel = new ViewModels.BookCategory();
            }

            viewModel.ID       = domainModel.ID;
            viewModel.Name     = domainModel.Name;
            viewModel.ParentID = domainModel.Parent == null ? -1 : domainModel.Parent.ID;

            return(viewModel);
        }