Esempio n. 1
0
        public async Task <ActionResult> CategoryDetails(Models.SearchCategorySelection model)
        {
            IcedMemories.Domain.Models.SearchCategory _category = await WorkManager.SearchCategoryManager.LoadAsync(model.Id);

            if (_category == null)
            {
                _category = new Domain.Models.SearchCategory();
            }
            _category.Name = model.Name;
            await WorkManager.SearchCategoryManager.SaveAsync(_category);

            foreach (Models.SearchCategoryOptionSelection _cOption in model.Options)
            {
                IcedMemories.Domain.Models.SearchCategoryOption _option = await WorkManager.SearchCategoryOptionManager.LoadAsync(_cOption.Id);

                if (_option == null)
                {
                    _option = new IcedMemories.Domain.Models.SearchCategoryOption();
                }
                _option.CategoryId = _category.Id;
                _option.Name       = _cOption.Name;
                await WorkManager.SearchCategoryOptionManager.SaveAsync(_option);
            }
            Models.SearchCategorySelection _returnCategory = Mapper.Map <IcedMemories.Domain.Models.SearchCategory, Models.SearchCategorySelection>(_category);
            try
            {
                _returnCategory.Options = Mapper.Map <IList <IcedMemories.Domain.Models.SearchCategoryOption>, IList <Models.SearchCategoryOptionSelection> >(await WorkManager.SearchCategoryOptionManager.GetCategoryOptionsAsync(_returnCategory.Id));
            }
            catch (Exception ex)
            {
            }
            return(PartialView("CategoryDetailsPartial", _returnCategory));
        }
Esempio n. 2
0
        public async Task<ActionResult> CategoryDetails(Models.SearchCategorySelection model)
        {
          IcedMemories.Domain.Models.SearchCategory _category = await WorkManager.SearchCategoryManager.LoadAsync(model.Id);
          if (_category == null)
          {
            _category = new Domain.Models.SearchCategory();
          }
          _category.Name = model.Name;
          await WorkManager.SearchCategoryManager.SaveAsync(_category);
          foreach(Models.SearchCategoryOptionSelection _cOption in model.Options)
          {
            IcedMemories.Domain.Models.SearchCategoryOption _option = await WorkManager.SearchCategoryOptionManager.LoadAsync(_cOption.Id);
            if(_option==null)
            {
              _option = new IcedMemories.Domain.Models.SearchCategoryOption();  
            }
            _option.CategoryId = _category.Id;
            _option.Name = _cOption.Name;
            await WorkManager.SearchCategoryOptionManager.SaveAsync(_option);
          }
          Models.SearchCategorySelection _returnCategory = Mapper.Map<IcedMemories.Domain.Models.SearchCategory, Models.SearchCategorySelection>(_category);
          try
          { 
            _returnCategory.Options = Mapper.Map<IList<IcedMemories.Domain.Models.SearchCategoryOption>, IList<Models.SearchCategoryOptionSelection>>(await WorkManager.SearchCategoryOptionManager.GetCategoryOptionsAsync(_returnCategory.Id));
          }
          catch(Exception ex)
          {

          }
          return PartialView("CategoryDetailsPartial", _returnCategory);
        }