Ejemplo n.º 1
0
        public CodeItemViewModel GetCodeItemViewModel(int id)
        {
            var model     = CodeItemRepository.GetByKey(id);
            var viewModel = AutoMapper.Mapper.Map <CodeItem, CodeItemViewModel>(model);

            return(viewModel);
        }
Ejemplo n.º 2
0
 public void SaveCodeItem(CodeItemViewModel viewModel)
 {
     if (viewModel.Id == 0)
     {
         var model = AutoMapper.Mapper.Map <CodeItemViewModel, CodeItem>(viewModel);
         CodeItemRepository.Insert(model);
     }
     else
     {
         var model = CodeItemRepository.GetByKey(viewModel.Id);
         AutoMapper.Mapper.Map <CodeItemViewModel, CodeItem>(viewModel, model);
         CodeItemRepository.Update(model);
     }
     CleanCache();
 }