crm: refactoring
This commit is contained in:
parent
2b1b3e508f
commit
1fac4bc1fe
@ -348,12 +348,8 @@ namespace ASC.CRM.Api
|
||||
[FromQuery] ApiDateTime toDate)
|
||||
{
|
||||
IEnumerable<ContactDto> result;
|
||||
|
||||
OrderBy contactsOrderBy;
|
||||
|
||||
ContactSortedByType sortBy;
|
||||
|
||||
|
||||
|
||||
var searchString = _apiContext.FilterValue;
|
||||
|
||||
|
@ -26,7 +26,10 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
using ASC.Api.Core;
|
||||
using ASC.Common;
|
||||
@ -116,8 +119,6 @@ namespace ASC.CRM.ApiModels
|
||||
}
|
||||
|
||||
[DataContract(Name = "contact", Namespace = "")]
|
||||
[KnownType(typeof(PersonDto))]
|
||||
[KnownType(typeof(CompanyDto))]
|
||||
public class ContactDto : ContactBaseDto, IMapFrom<ASC.CRM.Core.Entities.Contact>
|
||||
{
|
||||
public ContactDto()
|
||||
@ -125,16 +126,6 @@ namespace ASC.CRM.ApiModels
|
||||
|
||||
}
|
||||
|
||||
//protected ContactDto(Contact contact)
|
||||
// : base(contact)
|
||||
//{
|
||||
// CreateBy = EmployeeWraper.Get(contact.CreateBy);
|
||||
// Created = (ApiDateTime)contact.CreateOn;
|
||||
// About = contact.About;
|
||||
// Industry = contact.Industry;
|
||||
//}
|
||||
|
||||
|
||||
public IEnumerable<Address> Addresses { get; set; }
|
||||
public EmployeeWraper CreateBy { get; set; }
|
||||
public ApiDateTime Created { get; set; }
|
||||
@ -190,50 +181,45 @@ namespace ASC.CRM.ApiModels
|
||||
public ContactInfoDto Email { get; set; }
|
||||
}
|
||||
|
||||
|
||||
[DataContract(Name = "contactBase", Namespace = "")]
|
||||
public class ContactBaseWithPhoneDto : ContactBaseDto
|
||||
{
|
||||
public ContactInfoDto Phone { get; set; }
|
||||
}
|
||||
|
||||
public class ContactDtoJsonConverter : JsonConverter<ContactDto>
|
||||
{
|
||||
public override ContactDto Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, ContactDto value, JsonSerializerOptions options)
|
||||
{
|
||||
if (value is PersonDto)
|
||||
{
|
||||
JsonSerializer.Serialize(writer, (PersonDto)value!, options);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (value is CompanyDto)
|
||||
{
|
||||
JsonSerializer.Serialize(writer, (CompanyDto)value!, options);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (value is ContactDto)
|
||||
{
|
||||
JsonSerializer.Serialize(writer, value!, options);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Contact base information
|
||||
@ -275,11 +261,7 @@ namespace ASC.CRM.ApiModels
|
||||
[DataContract(Name = "contact_task", Namespace = "")]
|
||||
public class ContactWithTaskDto
|
||||
{
|
||||
|
||||
public TaskBaseDto Task { get; set; }
|
||||
|
||||
|
||||
public ContactDto Contact { get; set; }
|
||||
}
|
||||
|
||||
}
|
@ -1,9 +1,16 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
using ASC.Api.Core;
|
||||
using ASC.Common;
|
||||
using ASC.CRM.Api;
|
||||
using ASC.CRM.ApiModels;
|
||||
using ASC.CRM.Mapping;
|
||||
using ASC.Web.CRM.HttpHandlers;
|
||||
|
||||
@ -58,7 +65,7 @@ namespace ASC.CRM
|
||||
DIHelper.TryAdd<TaskCategoryDtoTypeConverter>();
|
||||
DIHelper.TryAdd<TaskDtoTypeConverter>();
|
||||
DIHelper.TryAdd<CustomFieldDtoTypeConverter>();
|
||||
|
||||
|
||||
services.AddAutoMapper(Assembly.GetExecutingAssembly());
|
||||
}
|
||||
|
||||
@ -110,5 +117,21 @@ namespace ASC.CRM
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public override JsonConverter[] Converters
|
||||
{
|
||||
get
|
||||
{
|
||||
var jsonConverters = new List<JsonConverter>
|
||||
{
|
||||
new ContactDtoJsonConverter()
|
||||
};
|
||||
|
||||
return jsonConverters.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user