Beispiel #1
0
        public IHttpActionResult GetLeadById(int?Id)
        {
            var response   = new DataResponse <EntityLead>();
            var repository = new RepositoryLead();

            if (Id.HasValue)
            {
                response = repository.GetLeadById(Id.Value);
            }
            else
            {
                response.Model          = new EntityLead();
                response.Model.Practice = new Business.Entity.Practice.EntityPractice();
            }
            return(Ok <DataResponse>(response));
        }
Beispiel #2
0
        public FileStreamResult pdf(PDFModel PDFModel)
        {
            if (PDFModel.IsAccount)
            {
                var repository = new RepositoryAccount();
                var model      = repository.GetAccountById(PDFModel.Id).Model;
                ViewData.Model = new PDFViewModel
                {
                    Practice      = model.Practice,
                    Providers     = model.Practice.Providers,
                    Address       = model.Practice.Address,
                    CreatedByName = model.CreatedByName,
                    CreatedOn     = model.CreatedOn,
                    EnrolledDate  = model.EnrolledDate,
                    Rep           = model.Rep,
                };

                PDFModel.Content = RazorHelper.RenderRazorViewToString("~/Views/Shared/accountPDF.cshtml", this);
            }
            else
            {
                var repository = new RepositoryLead();
                var model      = repository.GetLeadById(PDFModel.Id).Model;
                ViewData.Model = new PDFViewModel
                {
                    Practice      = model.Practice,
                    Providers     = model.Practice.Providers,
                    Address       = model.Practice.Address,
                    CreatedByName = model.CreatedByName,
                    CreatedOn     = model.CreatedOn,
                    Rep           = model.Rep,
                };

                PDFModel.Content = RazorHelper.RenderRazorViewToString("~/Views/Shared/leadPDF.cshtml", this);
            }
            var accountPdfContent = @"<?xml version=""1.0"" encoding=""UTF-8""?>
                                <!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Strict//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"">
                                <html xmlns=""http://www.w3.org/1999/xhtml"" xml:lang=""en"" lang=""en"">
                                <head>
                                    <title>Account Details</title>
                                </head>
                                <body>" + PDFModel.Content + "</body></html>";

            var leadPdfContent = @"<?xml version=""1.0"" encoding=""UTF-8""?>
                                <!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Strict//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"">
                                <html xmlns=""http://www.w3.org/1999/xhtml"" xml:lang=""en"" lang=""en"">
                                <head>
                                    <title>Lead Details</title>
                                </head>
                                <body>" + PDFModel.Content + "</body></html>";

            var bytes = System.Text.Encoding.UTF8.GetBytes(PDFModel.IsAccount ? accountPdfContent : leadPdfContent);

            using (var input = new MemoryStream(bytes))
            {
                var output = new MemoryStream();

                var document = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 0, 0, 0, 0);
                var writer   = PdfWriter.GetInstance(document, output);

                writer.CloseStream = false;
                document.Open();

                var xmlWorker = XMLWorkerHelper.GetInstance();
                xmlWorker.ParseXHtml(writer, document, input, default(Stream));

                document.Close();
                output.Position = 0;

                return(new FileStreamResult(output, "application/pdf"));
            }
        }
Beispiel #3
0
        public IHttpActionResult GetVmLeadObject(int?id)
        {
            var response = new DataResponse <VMLead>();

            if (id.HasValue)
            {
                var repository = new RepositoryLead();
                var model      = repository.GetLeadById(id.Value).Model;
                if (model != null)
                {
                    var PracticeAddress = model.Practice.Address.Where(a => a.AddressTypeId == 1).Select(a => new VMLocation
                    {
                        AddressId    = a.AddressId,
                        PhoneId      = a.Phone.Count() > 0 ? a.Phone.First().PhoneId : 0,
                        AddressLine1 = a.Line1,
                        AddressLine2 = a.Line2,
                        PhoneNumber  = a.Phone.Count() > 0 ? a.Phone.First().PhoneNumber : null,
                        Extension    = a.Phone.Count() > 0 ? a.Phone.First().Extension : null,
                        City         = a.City,
                        Fax          = a.Fax,
                        ManagerName  = a.ManagerName,
                        StateId      = a.StateId,
                        Zip          = a.Zip
                    }).FirstOrDefault();

                    int?SpecialityTypeId = model.Practice.SpecialityTypeId,
                       RepId             = model.Rep.Id,
                       RepGroupId        = model.Rep.GroupId;

                    response.Model = new VMLead
                    {
                        Id                   = id.Value,
                        PracticeName         = model.Practice.Name,
                        PracticeId           = model.PracticeId,
                        SpecialityTypeId     = SpecialityTypeId == null ? 0 : (int)SpecialityTypeId,
                        ServiceInterest      = model.LeadServiceIntrest,
                        RepGroupId           = RepGroupId == null ? 0 : (int)RepGroupId,
                        RepId                = RepId == null ? 0 : (int)RepId,
                        AddressId            = PracticeAddress != null ? PracticeAddress.AddressId : null,
                        PracticeAddressLine1 = PracticeAddress != null ? PracticeAddress.AddressLine1 : null,
                        PracticeAddressLine2 = PracticeAddress != null ? PracticeAddress.AddressLine2 : null,
                        PhoneNumber          = PracticeAddress != null ? PracticeAddress.PhoneNumber : null,
                        PhoneExtension       = PracticeAddress != null ? PracticeAddress.Extension : null,
                        City                 = PracticeAddress != null ? PracticeAddress.City : null,
                        Fax                  = PracticeAddress != null ? PracticeAddress.Fax : null,
                        StateId              = PracticeAddress != null ? PracticeAddress.StateId : null,
                        Zip                  = PracticeAddress != null ? PracticeAddress.Zip : null,
                        LeadSourceId         = model.LeadSourceId,
                        NewSpectialityName   = model.Practice.SpecialityType,
                        SpecialityId         = model.Practice.Specialities.Count() == 1 ? model.Practice.Specialities.First().PracticeSpecialityId : 0,
                        SpecialityIds        = model.Practice.Specialities.Count() > 0 ? model.Practice.Specialities.Select(a => a.PracticeSpecialityId.ToString()).ToArray() : null,
                        OtherLeadSource      = model.OtherLeadSource
                    };

                    response.Model.Locations = model.Practice.Address.Where(s => s.AddressTypeId != 1).Select(a => new VMLocation
                    {
                        AddressId     = a.AddressId,
                        PhoneId       = a.Phone.Count() > 0 ? a.Phone.FirstOrDefault().PhoneId : 0,
                        AddressLine1  = a.Line1,
                        AddressLine2  = a.Line2,
                        PhoneNumber   = a.Phone.Count() > 0 ? a.Phone.First().PhoneNumber : null,
                        Extension     = a.Phone.Count() > 0 ? a.Phone.First().Extension : null,
                        City          = a.City,
                        AddressTypeId = a.AddressTypeId,
                        ManagerName   = a.ManagerName,
                        StateId       = a.StateId,
                        Zip           = a.Zip
                    }).ToList();

                    response.Model.Providers = model.Practice.Providers.Select(a => new VMProvider
                    {
                        Id         = a.ProviderId,
                        DegreeId   = a.DegreeId,
                        FirstName  = a.FirstName,
                        LastName   = a.LastName,
                        MiddleName = a.MiddleName,
                        NPI        = a.NPI,
                        Location   = a.Address != null ? new VMLocation
                        {
                            AddressId     = a.Address.AddressId,
                            PhoneId       = a.Address.Phone.Count() > 0 ? a.Address.Phone.FirstOrDefault().PhoneId : 0,
                            AddressLine1  = a.Address.Line1,
                            AddressLine2  = a.Address.Line2,
                            PhoneNumber   = a.Address.Phone.Count() > 0 ? a.Address.Phone.First().PhoneNumber : null,
                            Extension     = a.Address.Phone.Count() > 0 ? a.Address.Phone.First().Extension : null,
                            City          = a.Address.City,
                            ManagerName   = a.Address.ManagerName,
                            StateId       = a.Address.StateId,
                            Zip           = a.Address.Zip,
                            AddressTypeId = a.Address.AddressTypeId
                        } : response.Model.Locations.FirstOrDefault()
                    }).ToList();
                    response.Status = DataResponseStatus.OK;
                    return(Ok <DataResponse>(response));
                }
            }

            response.Model  = new VMLead();
            response.Status = DataResponseStatus.OK;
            return(Ok <DataResponse>(response));
        }