Example #1
0
    public async Task <AppSrvResult> UpdateAsync(long id, CfgUpdationDto input)
    {
        var exists = await _cfgRepository.AnyAsync(c => c.Name.Equals(input.Name.Trim()) && c.Id != id);

        if (exists)
        {
            return(Problem(HttpStatusCode.BadRequest, "参数名称已经存在"));
        }

        var entity = Mapper.Map <SysCfg>(input);

        entity.Id = id;
        var updatingProps = UpdatingProps <SysCfg>(x => x.Name, x => x.Value, x => x.Description);
        await _cfgRepository.UpdateAsync(entity, updatingProps);

        return(AppSrvResult());
    }
Example #2
0
        public async Task <AppSrvResult> UpdateAsync(long id, CfgUpdationDto input)
        {
            var exist = (await _cacheService.GetAllCfgsFromCacheAsync()).Exists(c => c.Name.EqualsIgnoreCase(input.Name) && c.Id != id);

            if (exist)
            {
                return(Problem(HttpStatusCode.BadRequest, "参数名称已经存在"));
            }

            var entity = Mapper.Map <SysCfg>(input);

            entity.Id = id;
            var updatingProps = UpdatingProps <SysCfg>(x => x.Name, x => x.Value, x => x.Description);
            await _cfgRepository.UpdateAsync(entity, updatingProps);

            return(AppSrvResult());
        }
Example #3
0
 public async Task <ActionResult <long> > UpdateAsync([FromRoute] long id, [FromBody] CfgUpdationDto input)
 {
     return(Result(await _cfgAppService.UpdateAsync(id, input)));
 }