public Task<StatusData<ContactResponse>> UpdateContact(UpdateContactRequest request, SystemSession session)
 {
     // return _unitOfWork.Profile.UpdateContact(request);
     return _jUnitOfWork.Profile.UpdateContact(request, session);
 }
        public virtual async Task<StatusData<ContactResponse>> UpdateContact(UpdateContactRequest request,
            SystemSession session)
        {
            var chatNetworks = string.Empty;
            if (request.ChatNetworks != null && request.ChatNetworks.Any())
            {
                var sb = new StringBuilder();
                foreach (var chatNetwork in request.ChatNetworks)
                    sb.Append(chatNetwork).Append("|");
                chatNetworks = sb.ToString().Substring(0, sb.Length - 1);
            }

            var customContacts = string.Empty;
            if (request.CustomContacts != null && request.CustomContacts.Any())
            {
                var sb = new StringBuilder();
                foreach (var customContact in request.CustomContacts)
                    sb.Append(customContact).Append("|");
                customContacts = sb.ToString().Substring(0, sb.Length - 1);
            }

            var serviceRequest = new UserContactDetails
            {
                ContactId = request.ContactId,
                StrChatNetWorks = chatNetworks,
                StrContactCustoms = customContacts,
                Address = request.Address,
                Email = request.Email,
                Fax = request.Fax,
                Mobile = request.Mobile,
                Phone = request.Phone,
                Website = request.Website,
                CompanyUserId =
                    (int)
                        (request.TemporaryContact != null && request.TemporaryContact.CompanyUserId != null
                            ? request.TemporaryContact.CompanyUserId
                            : 0),
                StartDate = request.TemporaryContact != null ? request.TemporaryContact.StartDate.ToString() : null,
                EndDate = (request.TemporaryContact != null) ? request.TemporaryContact.EndDate.ToString() : null,
                UserId = session.UserId,
                Username = session.UserName,
                Mode = (byte)SystemDbStatus.Updated
            };

            var response =
                await
                    Task.Factory.StartNew(() => Client.UserService.upsertContacts(serviceRequest, session.GetSession()))
                        .ConfigureAwait(false);

            var data = new StatusData<ContactResponse>
            {
                Status = (SystemDbStatus)response.Dbstatus.DbStatusCode,
                Message = response.Dbstatus.DbStatusMsg,
                SubStatus = response.Dbstatus.DbSubStatusCode
            };

            if (data.Status.IsOperationSuccessful())
            {
                data.Data = new ContactResponse
                {
                    ContactId = response.ContactId,
                    ContactChatNetworks =
                        response.ContactChatNetworkId != null
                            ? response.ContactChatNetworkId.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries)
                                .Select(x => Convert.ToInt32(x))
                                .ToList()
                            : null,
                    ContactCustoms =
                        response.CustomContactsCustomeIds != null
                            ? response.CustomContactsCustomeIds.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries)
                                .Select(x => Convert.ToInt64(x))
                                .ToList()
                            : null
                };
            }
            return data;
        }