Beispiel #1
0
        public override APMCDto EntityToEntityDto(APMC entity)
        {
            APMCDto apmcDto = Mapper.Map <APMC, APMCDto>(entity);

            #region APMCAddress
            if (entity.Address != null)
            {
                apmcDto.Address = Mapper.Map <Address, AddressDto>(entity.Address);

                if (entity.Address.CityVillage != null)
                {
                    apmcDto.Address.CityVillage = Mapper.Map <CityVillage, CityVillageDto>(entity.Address.CityVillage);
                    if (entity.Address.CityVillage.DistrictOfCityVillage != null)
                    {
                        apmcDto.Address.CityVillage.DistrictOfCityVillage = Mapper.Map <District, DistrictDto>(entity.Address.CityVillage.DistrictOfCityVillage);
                        if (entity.Address.CityVillage.DistrictOfCityVillage.StateOfDistrict != null)
                        {
                            apmcDto.Address.CityVillage.DistrictOfCityVillage.StateOfDistrict =
                                Mapper.Map <State, StateDto>(entity.Address.CityVillage.DistrictOfCityVillage.StateOfDistrict);
                            if (entity.Address.CityVillage.DistrictOfCityVillage.StateOfDistrict.StateInCountry != null)
                            {
                                apmcDto.Address.CityVillage.DistrictOfCityVillage.StateOfDistrict.StateInCountry =
                                    Mapper.Map <Country, CountryDto>(entity.Address.CityVillage.DistrictOfCityVillage.StateOfDistrict.StateInCountry);
                            }
                        }
                    }
                }
            }
            #endregion

            #region APMC ContactDetails
            apmcDto.ContactNos.Clear();
            if (entity.ContactNos != null)
            {
                foreach (ContactDetails usercontactdetails in entity.ContactNos)
                {
                    ContactDetailsDto contactdto = Mapper.Map <ContactDetails, ContactDetailsDto>(usercontactdetails);
                    apmcDto.ContactNos.Add(contactdto);
                }
            }
            #endregion

            #region APMC Of Clients
            apmcDto.APMCOfClients.Clear();
            if (entity.APMCOfClients != null)
            {
                foreach (Client client in entity.APMCOfClients)
                {
                    ClientDto clientDto = Mapper.Map <Client, ClientDto>(client);
                    apmcDto.APMCOfClients.Add(clientDto);
                }
            }
            #endregion

            return(apmcDto);
        }
Beispiel #2
0
        public async Task <ContactDetailsDto> GetContactDetailsAsync(int id, CancellationToken cancellationToken)
        {
            this.securityService.Ensure(SecurityEntityTypes.Contact, SecurityMethods.View);

            Contact contact = await this.GetContactModelWithSkillsAsync(id, cancellationToken);

            ContactDetailsDto contactDto = this.mapper.Map <ContactDetailsDto>(contact);

            return(contactDto);
        }
Beispiel #3
0
        public static string GetMobileNoFromContacts(IList <ContactDetailsDto> contacts)
        {
            ContactDetailsDto contact = new ContactDetailsDto();
            IEnumerable <ContactDetailsDto> mobileContact = contacts.Where(x => x.ContactNoType == ContactType.MobileNo);

            if (mobileContact.Count() > 0)
            {
                contact = mobileContact.FirstOrDefault();
            }
            if (String.IsNullOrEmpty(contact.ContactNo))
            {
                contact.ContactNo = string.Empty;
            }
            return(contact.ContactNo);
        }
        public ContactDetailsDto FindById(int id)
        {
            try
            {
                var contact           = _db.Set <Contact>().First(x => x.Id == id);
                var contactAddressIds = contact.ContactAddresses.Select(y => y.AddressId).ToList();
                var addresses         = _db.Address.Where(x => contactAddressIds.Contains(x.Id)).ToList();

                var addressListDto = new List <AddressDtoDetails>();
                foreach (var adr in contact.ContactAddresses)
                {
                    var address = addresses.First(x => x.Id == adr.Id);
                    var adrDto  = new AddressDtoDetails()
                    {
                        AddressType = adr.AddressType,
                        Id          = address.Id,
                        City        = address.City,
                        Country     = address.Country,
                        Line1       = address.Line1,
                        Line2       = address.Line2,
                        Line3       = address.Line3,
                        PostCode    = address.PostCode,
                        Version     = address.Version
                    };
                    addressListDto.Add(adrDto);
                }

                var contactDetails = new ContactDetailsDto()
                {
                    Id        = contact.Id,
                    Email     = contact.Email,
                    FirstName = contact.FirstName,
                    LastName  = contact.LastName,
                    Title     = contact.Title,
                    Version   = contact.Version,
                    Addresses = addressListDto
                };

                return(contactDetails);
            }
            catch (Exception ex)
            {
                //log exception
                return(null);
            }
        }
        public IList <ContactDetailsDto> GetContactsFromString(string contactDetails)
        {
            IList <ContactDetailsDto> contacts = new List <ContactDetailsDto>();

            if (!String.IsNullOrEmpty(contactDetails))
            {
                contactDetails = contactDetails.TrimEnd(';');
                foreach (string contactDetail in contactDetails.Split(';'))
                {
                    string[]          ContactDetail = contactDetail.Split(',');
                    ContactDetailsDto contact       = new ContactDetailsDto
                    {
                        ContactNoType = GetContactType(ContactDetail[0]),
                        STDCode       = ContactDetail[1],
                        ContactNo     = ContactDetail[2]
                    };
                    contacts.Add(contact);
                }
            }
            return(contacts);
        }
        public override ClientPrimaryContactPersonDto EntityToEntityDto(ClientPrimaryContactPerson entity)
        {
            ClientPrimaryContactPersonDto clientPrimaryContactPersonDto = Mapper.Map <ClientPrimaryContactPerson, ClientPrimaryContactPersonDto>(entity);

            if (entity != null)
            {
                #region ClientPrimaryContactPerson Address
                if (entity.ClientPrimaryContactPersonAddress != null)
                {
                    AddressService addressService = new AddressService();
                    clientPrimaryContactPersonDto.ClientPrimaryContactPersonAddress = addressService.EntityToEntityDto(entity.ClientPrimaryContactPersonAddress);
                }
                #endregion

                #region ClientPrimaryContactPerson Designation
                if (entity.ClientPrimaryContactPersonDesignation != null)
                {
                    DesignationService designationService = new DesignationService();
                    clientPrimaryContactPersonDto.ClientPrimaryContactPersonDesignation = designationService.EntityToEntityDto(entity.ClientPrimaryContactPersonDesignation);
                }
                #endregion

                #region ClientPrimaryContactPerson ContactDetails
                clientPrimaryContactPersonDto.ClientPrimaryContacts.Clear();
                if (entity.ClientPrimaryContacts != null)
                {
                    foreach (ContactDetails PrimaryContactPersoncontacts in entity.ClientPrimaryContacts)
                    {
                        ContactDetailsDto contactdto = new ContactDetailsDto();
                        contactdto = Mapper.Map <ContactDetails, ContactDetailsDto>(PrimaryContactPersoncontacts);
                        clientPrimaryContactPersonDto.ClientPrimaryContacts.Add(contactdto);
                    }
                }
                #endregion
            }
            return(clientPrimaryContactPersonDto);
        }
 public Task PublishContactDeletedEvent(ContactDetailsDto contactDto, CancellationToken cancellationToken)
 {
     return(_contactHub.Clients.All.SendAsync(nameof(ISignalRClient.ContactDeletedEvent), contactDto, cancellationToken));
 }
 public ContactDeletedEvent(ContactDetailsDto dto)
 {
     Dto = dto;
 }
Beispiel #9
0
        public ActionResult AddNewApmcUsingPopup()
        {
            UserDto currentUserDto = (UserDto)Session[Constants.SKCURRENTUSER];
            APMCDto apmcDto        = new APMCDto();
            CityVillageServiceClient cityVillageServiceClient = new CityVillageServiceClient();

            client = new APMCServiceClient();
            try
            {
                apmcDto.Name    = Request.Params["ApmcName"];
                apmcDto.Address = new AddressDto();
                apmcDto.Address.AddressLine1 = Request.Params["APMCAddress"];
                apmcDto.Address.PIN          = Request.Params["ApmcPin"];
                apmcDto.Website     = Request.Params["ApmcWebsite"];
                apmcDto.Email1      = Request.Params["ApmcEmail1"];
                apmcDto.Email2      = Request.Params["ApmcEmail2"];
                apmcDto.Address.PIN = Request.Params["ApmcPin"];
                apmcDto.Status      = Request.Params["Status"];

                apmcDto.CreatedBy    = currentUserDto.UserId;
                apmcDto.CreatedDate  = DateTime.Now;
                apmcDto.ModifiedBy   = currentUserDto.UserId;
                apmcDto.ModifiedDate = DateTime.Now;

                Query     query        = new Query();
                Criterion criteriaName = new Criterion("Name", Request.Params["ApmcPlace"], CriteriaOperator.Equal);
                query.Add(criteriaName);
                query.QueryOperator         = QueryOperator.And;
                apmcDto.Address.CityVillage = cityVillageServiceClient.FindByQuery(query).Entities[0];

                apmcDto.ContactNos = new List <ContactDetailsDto>();
                for (int i = 0; i < 4; i++)
                {
                    if (Request.Params["ApmcContactNos" + i] != null)
                    {
                        ContactDetailsDto contactDetailsDto = new ContactDetailsDto();
                        contactDetailsDto.ContactNo = Request.Params["ApmcContactNos" + i];

                        switch (Request.Params["ApmcContactNos" + i + "_ContactType"])
                        {
                        case "MobileNo":
                            contactDetailsDto.ContactNoType = ContactType.MobileNo;
                            break;

                        case "OfficeNo":
                            contactDetailsDto.ContactNoType = ContactType.OfficeNo;
                            contactDetailsDto.STDCode       = Request.Params["ContactNos_" + i + "__STDCode"];
                            break;

                        case "ResidenceNo":
                            contactDetailsDto.ContactNoType = ContactType.ResidenceNo;
                            contactDetailsDto.STDCode       = Request.Params["ContactNos_" + i + "__STDCode"];
                            break;

                        case "Fax":
                            contactDetailsDto.ContactNoType = ContactType.Fax;
                            contactDetailsDto.STDCode       = Request.Params["ContactNos_" + i + "__STDCode"];
                            break;
                        }
                        apmcDto.ContactNos.Add(contactDetailsDto);
                    }
                }
                apmcDto = client.Create(apmcDto, currentUserDto.UserName);
                if (apmcDto.Response.HasWarning)
                {
                    ViewData["Apmcpresent"] = ErrorAndValidationMessages.APMCExists;
                }
                else
                {
                    ViewData["ApmcSaved"] = string.Format(ClientResources.APMCSaved, apmcDto.Name);
                }
            }
            catch (Exception ex)
            {
                return(View("ErrorPage"));
            }
            finally
            {
                if (client != null && client.State == System.ServiceModel.CommunicationState.Opened)
                {
                    client.Close();
                }

                if (cityVillageServiceClient != null && cityVillageServiceClient.State == System.ServiceModel.CommunicationState.Opened)
                {
                    cityVillageServiceClient.Close();
                }
            }
            return(null);
        }
Beispiel #10
0
 public ContactCreatedEvent(ContactDetailsDto contactDto)
 {
     ContactDto = contactDto;
 }
Beispiel #11
0
        public override BankBranchDto EntityToEntityDto(BankBranch entity)
        {
            BankBranchDto bankbranchDto = Mapper.Map <BankBranch, BankBranchDto>(entity);

            if (entity != null)
            {
                bankbranchDto.BranchOfBank = Mapper.Map <Bank, BankDto>(entity.BranchOfBank);

                #region BranchAddress
                if (entity.BranchAddress != null)
                {
                    bankbranchDto.BranchAddress = Mapper.Map <Address, AddressDto>(entity.BranchAddress);
                    if (entity.BranchAddress.CityVillage != null)
                    {
                        bankbranchDto.BranchAddress.CityVillage = Mapper.Map <CityVillage, CityVillageDto>(entity.BranchAddress.CityVillage);
                        bankbranchDto.BranchAddress.CityVillage.DistrictOfCityVillage = Mapper.Map <District, DistrictDto>(entity.BranchAddress.CityVillage.DistrictOfCityVillage);
                        bankbranchDto.BranchAddress.CityVillage.DistrictOfCityVillage.StateOfDistrict = Mapper.Map <State, StateDto>(entity.BranchAddress.CityVillage.DistrictOfCityVillage.StateOfDistrict);
                    }
                }
                #endregion

                #region BranchContactNos
                bankbranchDto.BranchContactNos.Clear();
                if (entity.BranchContactNos != null)
                {
                    foreach (ContactDetails bankbranchcontactdetails in entity.BranchContactNos)
                    {
                        ContactDetailsDto contactdto = new ContactDetailsDto();
                        contactdto = Mapper.Map <ContactDetails, ContactDetailsDto>(bankbranchcontactdetails);
                        bankbranchDto.BranchContactNos.Add(contactdto);
                    }
                }
                #endregion

                #region WeeklyOffDay & WeeklyHalfDay
                bankbranchDto.WeeklyOffDay  = Mapper.Map <WeeklyOffDays, WeeklyOffDaysDto>(entity.WeeklyOffDay);
                bankbranchDto.WeeklyHalfDay = Mapper.Map <WeeklyHalfDay, WeeklyHalfDayDto>(entity.WeeklyHalfDay);
                #endregion

                #region BranchOfClientSubscriptionPayment
                bankbranchDto.BranchOfClientSubscriptionPayment.Clear();
                if (entity.BranchOfClientSubscriptionPayment != null)
                {
                    foreach (ClientSubscriptionPaymentDetails clientsubscriptionpayment in entity.BranchOfClientSubscriptionPayment)
                    {
                        ClientSubscriptionPaymentDetailsDto clientsubscriptionpaymentDto = Mapper.Map <ClientSubscriptionPaymentDetails, ClientSubscriptionPaymentDetailsDto>(clientsubscriptionpayment);
                        bankbranchDto.BranchOfClientSubscriptionPayment.Add(clientsubscriptionpaymentDto);
                    }
                }
                #endregion

                #region BranchOfClientPartner
                bankbranchDto.BranchOfClientPartner.Clear();
                if (entity.BranchOfClientPartner != null)
                {
                    foreach (ClientPartnerBankDetails clientpartnerbank in entity.BranchOfClientPartner)
                    {
                        ClientPartnerBankDetailsDto clientpartnerbankDto = Mapper.Map <ClientPartnerBankDetails, ClientPartnerBankDetailsDto>(clientpartnerbank);
                        bankbranchDto.BranchOfClientPartner.Add(clientpartnerbankDto);
                    }
                }
                #endregion
            }
            return(bankbranchDto);
        }
Beispiel #12
0
        public async Task <IHttpActionResult> GetContactDetailsAsync(int id, CancellationToken cancellationToken = default(CancellationToken))
        {
            ContactDetailsDto contact = await this.contactService.GetContactDetailsAsync(id, cancellationToken);

            return(this.Ok(contact));
        }