コード例 #1
0
        internal DictionaryDto Map(DictionaryDto a, LanguageTextDto p)
        {
            // Terminating call.  Since we can return null from this function
            // we need to be ready for PetaPoco to callback later with null
            // parameters
            if (a == null)
            {
                return(Current);
            }

            // Is this the same DictionaryItem as the current one we're processing
            if (Current != null && Current.UniqueId == a.UniqueId)
            {
                // Yes, just add this LanguageTextDto to the current DictionaryItem's collection
                Current.LanguageTextDtos.Add(p);

                // Return null to indicate we're not done with this DictionaryItem yet
                return(null);
            }

            // This is a different DictionaryItem to the current one, or this is the
            // first time through and we don't have a Tab yet

            // Save the current DictionaryItem
            var prev = Current;

            // Setup the new current DictionaryItem
            Current = a;
            Current.LanguageTextDtos = new List <LanguageTextDto>();
            Current.LanguageTextDtos.Add(p);

            // Return the now populated previous DictionaryItem (or null if first time through)
            return(prev);
        }
コード例 #2
0
        public async Task <ActionResult> SubscribeAsync(Guid userId, [FromBody] DictionaryDto dictionary)
        {
            _service.Token = await getAccessToken();

            await _service.SubscribeAsync(userId, _mapper.Map <Dictionary>(dictionary));

            return(Ok());
        }
コード例 #3
0
        public async Task <ActionResult> UpdateAsync([FromBody] DictionaryDto dictionary)
        {
            _service.Token = await getAccessToken();

            await _service.UpdateAsync(_mapper.Map <Dictionary>(dictionary));

            return(Ok());
        }
コード例 #4
0
        public async Task <ActionResult> InsertAsync([FromBody] DictionaryDto dictionary)
        {
            _service.Token = await getAccessToken();

            var inserted = await _service.InsertAsync(_mapper.Map <Dictionary>(dictionary));

            return(CreatedAtAction("GetDictionaryById", new { id = inserted.Id }, inserted));;
        }
コード例 #5
0
 /// <summary>
 /// 新增字典
 /// </summary>
 /// <param name="dto"></param>
 /// <returns></returns>
 public IHttpActionResult Post([FromBody] DictionaryDto dto)
 {
     if (ModelState.IsValid == false)
     {
         return(BadRequest(ModelState));
     }
     _dictionary.CreatDictionary(dto);
     return(Ok());
 }
コード例 #6
0
        public void EditDictionary(DictionaryDto dto)
        {
            var entity = Mapper.Map <DictionaryDto, Dictionary>(dto);

            using (var dbScope = _dbScopeFactory.Create())
            {
                var db = dbScope.DbContexts.Get <FireProjDbContext>();
                db.Update(entity, r => new { r.Description, ModifyBy = r.ModifyId, r.ModifyDate, r.Name, r.ParentId, r.Value });
                db.SaveChanges();
            }
        }
コード例 #7
0
        protected IDictionaryItem ConvertFromDto(DictionaryDto dto)
        {
            var entity = DictionaryItemFactory.BuildEntity(dto);

            entity.Translations = dto.LanguageTextDtos.EmptyNull()
                                  .Where(x => x.LanguageId > 0)
                                  .Select(x => DictionaryTranslationFactory.BuildEntity(x, dto.UniqueId))
                                  .ToList();

            return(entity);
        }
コード例 #8
0
        public void CreatDictionary(DictionaryDto dto)
        {
            var entity = Mapper.Map <DictionaryDto, Dictionary>(dto);

            entity.CreateDate = DateTime.Now;
            using (var dbScope = _dbScopeFactory.Create())
            {
                var db = dbScope.DbContexts.Get <FireProjDbContext>();
                db.Dictionary.Add(entity);
                db.SaveChanges();
            }
        }
コード例 #9
0
        public IDictionaryItem BuildEntity(DictionaryDto dto)
        {
            var item = new DictionaryItem(dto.Parent, dto.Key)
            {
                Id  = dto.PrimaryKey,
                Key = dto.UniqueId
            };

            //on initial construction we don't want to have dirty properties tracked
            // http://issues.umbraco.org/issue/U4-1946
            item.ResetDirtyProperties(false);
            return(item);
        }
コード例 #10
0
        public async Task Load()
        {
            dic_Genre generalGenre = new dic_Genre();

            generalGenre.name = "All/Any";
            dic_Product_type generalProductType = new dic_Product_type();

            generalProductType.name = "All/Any";
            dic_condition generalCondition = new dic_condition();

            generalCondition.name = "All/Any";
            using (var client = new HttpClient())
            {
                URLBuilder url     = new URLBuilder("/api/Dictionary/");
                var        request = new HttpRequestMessage()
                {
                    RequestUri = new Uri(url.URL),
                    Method     = HttpMethod.Get,
                };
                var response = await client.SendAsync(request);

                var contents = await response.Content.ReadAsStringAsync();

                if (!response.IsSuccessStatusCode)
                {
                    return;
                }
                DictionaryDto          result = JsonConvert.DeserializeObject <DictionaryDto>(contents);
                IEnumerable <GenreDto> genres = result.Genres;
                Genres.Add(new GenreWrapper(generalGenre));
                foreach (GenreDto g in genres)
                {
                    GenreWrapper wrap = g.createGenre();
                    Genres.Add(wrap);
                }
                IEnumerable <ConditionDto> conditions = result.Conditions;
                Conditions.Add(new ConditionWrapper(generalCondition));
                foreach (ConditionDto c in conditions)
                {
                    Conditions.Add(c.createCondition());
                }
                IEnumerable <ProductTypeDto> productTypes = result.ProductTypes;

                ProductTypes.Add(new ProductTypeWrapper(generalProductType));
                foreach (var p in productTypes)
                {
                    ProductTypes.Add(p.createProductType());
                }
            }
        }
コード例 #11
0
        public static string GetDictionaryText(IEnumerable <DictionaryDto> dictionaries, int tag, string value)
        {
            string        ret           = "";
            DictionaryDto dictionaryDto = dictionaries.Where(d => d.Tag == tag).FirstOrDefault();

            if (dictionaryDto != null)
            {
                DictionaryValueDto dictionaryValueDto = dictionaryDto.Values.Where(d => d.Value == value).FirstOrDefault();
                if (dictionaryValueDto != null)
                {
                    ret = dictionaryValueDto.Text;
                }
            }
            return(ret);
        }
コード例 #12
0
        public async Task <IHttpActionResult> Get()
        {
            var conditions   = _conditionAssembler.EntityToDto(await _conditionService.GetData(null));
            var genres       = _genreAssembler.EntityToDto(await _genreService.GetData(null));
            var productTypes = _productTypeAssembler.EntityToDto(await _productTypeService.GetData(null));

            var dto = new DictionaryDto()
            {
                Conditions   = conditions,
                Genres       = genres,
                ProductTypes = productTypes
            };

            return(Ok(dto));
        }
コード例 #13
0
        public static string GetDictionaryText(IEnumerable <DictionaryDto> dictionaries, int tag, string value)
        {
            string        ret           = "";
            DictionaryDto dictionaryDto = dictionaries.Where(d => d.Tag == tag).FirstOrDefault();

            if (dictionaryDto != null)
            {
                DictionaryValueDto dictionaryValueDto = dictionaryDto.Values.Where(d => d.Value.Equals(value, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                if (dictionaryValueDto != null)
                {
                    ret = dictionaryValueDto.Text;
                }
            }
            return(ret);
        }
コード例 #14
0
        public Result <DictionaryDto> Get(string key, string callback = "")
        {
            Result <DictionaryDto> result = new Result <DictionaryDto>();

            try
            {
                DictionaryDto dictionaryDto = dictionaryBLL.getByKey(key);
                result.succeed(dictionaryDto);
            }
            catch (Exception e)
            {
                result.fail(e.Message);
            }
            return(result);
        }
コード例 #15
0
 /// <summary>
 /// 根据id编辑字典信息
 /// </summary>
 /// <param name="id"></param>
 /// <param name="dto"></param>
 /// <returns></returns>
 public IHttpActionResult Put(int id, [FromBody] DictionaryDto dto)
 {
     //参数验证
     if (id == 0)
     {
         ModelState.AddModelError("id", "id不允许为空");
         return(BadRequest(ModelState));
     }
     if (ModelState.IsValid == false)
     {
         return(BadRequest(ModelState));
     }
     dto.Id = id;
     _dictionary.EditDictionary(dto);
     return(Ok());
 }
コード例 #16
0
 public ActionResult Edit(int id)
 {
     var dto = CommonContract.Dictionarys.Where(c => c.Id == id).Select(m =>
         new DictionaryDto
         {
             Id = m.Id,
             Name = m.Name,
             Value = m.Value,
             SortCode = m.SortCode,
             ParentId = m.Parent.Id,
             ParentName=m.Parent.Name
         }).SingleOrDefault();
     if (dto == null)
         dto = new DictionaryDto();
     return View(dto);
 }
コード例 #17
0
        public ActionResult Edit(int id)
        {
            var dto = CommonContract.Dictionarys.Where(c => c.Id == id).Select(m =>
                                                                               new DictionaryDto
            {
                Id         = m.Id,
                Name       = m.Name,
                Value      = m.Value,
                SortCode   = m.SortCode,
                ParentId   = m.Parent.Id,
                ParentName = m.Parent.Name
            }).SingleOrDefault();

            if (dto == null)
            {
                dto = new DictionaryDto();
            }
            return(View(dto));
        }
コード例 #18
0
    public static IDictionaryItem BuildEntity(DictionaryDto dto)
    {
        var item = new DictionaryItem(dto.Parent, dto.Key);

        try
        {
            item.DisableChangeTracking();

            item.Id  = dto.PrimaryKey;
            item.Key = dto.UniqueId;

            // reset dirty initial properties (U4-1946)
            item.ResetDirtyProperties(false);
            return(item);
        }
        finally
        {
            item.EnableChangeTracking();
        }
    }
コード例 #19
0
        public IDictionaryItem BuildEntity(DictionaryDto dto)
        {
            var item = new DictionaryItem(dto.Parent, dto.Key);

            try
            {
                item.DisableChangeTracking();

                item.Id  = dto.PrimaryKey;
                item.Key = dto.UniqueId;
                //on initial construction we don't want to have dirty properties tracked
                // http://issues.umbraco.org/issue/U4-1946
                item.ResetDirtyProperties(false);
                return(item);
            }
            finally
            {
                item.EnableChangeTracking();
            }
        }
コード例 #20
0
        protected IDictionaryItem ConvertFromDto(DictionaryDto dto)
        {
            var factory = new DictionaryItemFactory();
            var entity  = factory.BuildEntity(dto);

            var list = new List <IDictionaryTranslation>();

            foreach (var textDto in dto.LanguageTextDtos)
            {
                if (textDto.LanguageId <= 0)
                {
                    continue;
                }

                var translationFactory = new DictionaryTranslationFactory(dto.UniqueId);
                list.Add(translationFactory.BuildEntity(textDto));
            }
            entity.Translations = list;

            return(entity);
        }
コード例 #21
0
        public HttpResponseMessage GrammarSuggestions([FromBody] DictionaryDto _DictionaryObj)
        {
            List <Suggestions> _SuggestionsObj = new List <Suggestions>();

            try
            {
                if (string.IsNullOrEmpty(_DictionaryObj.text))
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, Messages.Bad_request_grammar));
                }
                else
                {
                    _SuggestionsObj = GrammarService.GrammarSuggestionsService(_DictionaryObj.text);
                    return(Request.CreateResponse <List <Suggestions> >(HttpStatusCode.OK, _SuggestionsObj));
                }
            }
            catch (Exception Ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, Ex.Message));
            }
        }
コード例 #22
0
        public HttpResponseMessage BulkChangeGrammar([FromBody] DictionaryDto _DictionaryObj)
        {
            Response _ResponseObj = new Response();

            try
            {
                if (string.IsNullOrEmpty(_DictionaryObj.text))
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, Messages.Bad_request_grammar));
                }
                else
                {
                    _ResponseObj = GrammarService.BulkChangeGrammarService(_DictionaryObj.text);
                    return(Request.CreateResponse <Response>(HttpStatusCode.OK, _ResponseObj));
                }
            }
            catch (Exception Ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, Ex.Message));
            }
        }
コード例 #23
0
        public ListResultDto <GetDictionary> GetDictionaryToChildren(DictionaryDto input)
        {
            List <Dictionary> list = new List <Dictionary>();
            var id = input.ParentID;//获取子父节点

            if (id == 0)
            {
                var demos = _dictionary.GetAll().Where(t => t.Id == input.Id).ToList();
                foreach (var item in demos)
                {
                    Dictionary node = new Dictionary();
                    node.Id       = item.Id;
                    node.ParentID = item.ParentID != null ? item.ParentID : 0;
                    node.Title    = item.Title;
                    node.Value    = item.Value;
                    node.Note     = item.Note;
                    node.Code     = item.Code;
                    node.Other    = item.Other;
                    node.Sort     = item.Sort;
                    list.Add(node);
                }
            }
            var demo = _dictionary.GetAll().Where(t => t.ParentID == id).ToList();//查询子节点

            foreach (var item in demo)
            {
                Dictionary node = new Dictionary();
                node.Id       = item.Id;
                node.ParentID = item.ParentID != null ? item.ParentID : 0;
                node.Title    = item.Title;
                node.Value    = item.Value;
                node.Note     = item.Note;
                node.Code     = item.Code;
                node.Other    = item.Other;
                node.Sort     = item.Sort;
                list.Add(node);
            }
            return(new ListResultDto <GetDictionary>(ObjectMapper.Map <List <GetDictionary> >(list)));
        }
コード例 #24
0
        protected IDictionaryItem ConvertFromDto(DictionaryDto dto, ILanguage[] allLanguages)
        {
            var factory = new DictionaryItemFactory();
            var entity  = factory.BuildEntity(dto);

            var list = new List <IDictionaryTranslation>();

            foreach (var textDto in dto.LanguageTextDtos)
            {
                //Assuming this is cached!
                var language = allLanguages.FirstOrDefault(x => x.Id == textDto.LanguageId);
                if (language == null)
                {
                    continue;
                }

                var translationFactory = new DictionaryTranslationFactory(dto.UniqueId, language);
                list.Add(translationFactory.BuildEntity(textDto));
            }
            entity.Translations = list;

            return(entity);
        }
コード例 #25
0
        public ListResultDto <GetDictionaryOutput> GetDictionariesByParentID(DictionaryDto input)
        {
            var data = (from a in _dictionary.GetAll()
                        where a.ParentID == input.Id
                        select new GetDictionaryOutput
            {
                Id = a.Id,
                ParentID = a.ParentID,
                Title = a.Title,
                Value = a.Value,
                Label = a.Title,
                Data = a.Value,
                Note = a.Note,
                Code = a.Code,
                Other = a.Other,
                Sort = a.Sort,
                ExpandedIcon = "",
                CollapsedIcon = "",
                ChildrenCount = _dictionary.GetAll().Where(r => r.ParentID == a.Id).Count()
            }).ToList();

            return(new ListResultDto <GetDictionaryOutput>(data));
        }
コード例 #26
0
 /// <summary>
 /// 转换为字典实体
 /// </summary>
 /// <param name="dto">字典数据传输对象</param>
 public static Dictionary ToEntity(this DictionaryDto dto)
 {
     if (dto == null)
     {
         return(new Dictionary());
     }
     return(new Dictionary(dto.Id.ToGuid(), dto.Id, 1)
     {
         Code = dto.Code,
         Text = dto.Text,
         PinYin = dto.PinYin,
         ParentId = dto.ParentId.ToGuidOrNull(),
         Enabled = dto.Enabled.SafeValue(),
         SortId = dto.SortId,
         Note = dto.Note,
         CreationTime = dto.CreationTime,
         CreatorId = dto.CreatorId,
         LastModificationTime = dto.LastModificationTime,
         LastModifierId = dto.LastModifierId,
         TenantId = dto.TenantId,
         IsDeleted = dto.IsDeleted.SafeValue(),
         Version = dto.Version,
     });
 }
コード例 #27
0
        public ActionResult EditDic(DictionaryDto dto)
        {
            OperationResult result = CommonContract.EditDictionarys(dto);

            return(Json(result.ToAjaxResult()));
        }
コード例 #28
0
 public ActionResult EditDic(DictionaryDto dto)
 {
     OperationResult result = CommonContract.EditDictionarys(dto);
     return Json(result.ToAjaxResult());
 }
コード例 #29
0
 private async Task LocalizeItem(DictionaryDto dic)
 {
     dic.Name = await _langResourceSingleQuery.Execute(dic.Name, Thread.CurrentThread.CurrentUICulture.IetfLanguageTag);
 }