Ejemplo n.º 1
0
 public static SuccessResponseDto Create(IEntityDto entity)
 {
     return(new SuccessResponseDto()
     {
         Entities = new List <IEntityDto>()
         {
             entity
         }
     });
 }
Ejemplo n.º 2
0
        public static async Task <HttpResponseMessage> PutByIdAsync <TPrimaryKey>(
            this HttpClient client,
            string path,
            ITestOutputHelper output,
            IEntityDto <TPrimaryKey> dto
            )
        {
            var builder = BuildPathWithEntity(client, path, dto);

            output.WriteLine($"METHOD PUT, url:'{builder.Uri.PathAndQuery}' dto:'{dto.ToJson()}'");
            return(await WriteApiErrorAsync(await client.PutAsync(builder.Uri.PathAndQuery, dto.ToStringContent()), output));
        }
Ejemplo n.º 3
0
        public static async Task <HttpResponseMessage> DeleteAsync <TPrimaryKey>(
            this HttpClient client,
            string path,
            ITestOutputHelper output,
            IEntityDto <TPrimaryKey> dto
            )
        {
            var builder = BuildPathWithEntity(client, path, dto);

            output.WriteLine($"METHOD DELETE, url:'{builder.Uri.PathAndQuery}'");
            return(await WriteApiErrorAsync(await client.DeleteAsync(builder.Uri.PathAndQuery), output));
        }
Ejemplo n.º 4
0
        public static void ModifyBy <T>(this IEntity <T> entity, IEntityDto <T> obj)
        {
            if (!entity.Id.Equals(obj.Id))
            {
                throw new Comm100Exception(100105, ErrorMessages.E100105);
            }

            foreach (var p in obj.GetType().GetProperties())
            {
                if (p.Name == "Id")
                {
                    continue;
                }
                var v = p.GetValue(obj);
                if (v != null)
                {
                    entity.GetType().GetProperty(p.Name)?.SetValue(entity, v);
                }
            }
        }
Ejemplo n.º 5
0
 public ModalHeaderViewModel(string title, IEntityDto <long> dto)
 {
     Title = $"{(dto.Id > 0 ? "编辑" : "新增")}{title}";
 }
 public Task <RoleDto> Get(IEntityDto <int> input)
 {
     throw new NotImplementedException();
 }
 public Task Delete(IEntityDto <int> input)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 8
0
 private static UriBuilder BuildPathWithEntity <TPrimaryKey>(HttpClient client, string path, IEntityDto <TPrimaryKey> dto)
 {
     return(BuildPathWithId(client, path, dto.Id));
 }
Ejemplo n.º 9
0
 public static TEntity ToEntity <TEntity, TEntityDto>(this IEntityDto entityDto)
     where TEntity : class, IEntity
 {
     return(entityDto == null ? null : Mapper.Map <TEntity>(entityDto));
 }
        public async Task <PersonDto> GetPersonForEdit(IEntityDto input)
        {
            var person = await _personRepository.GetAsync(input.Id);

            return(ObjectMapper.Map <PersonDto>(person));
        }
 protected void SetUpdateText(IEntityDto dto)
 {
     UpdateText = dto.Id.IsNullOrEmpty() ? "Criou" : "Atualizou";
 }