Exemplo n.º 1
0
        public async Task <IActionResult> ScancenterAppointment(
            [FromQuery] int page,
            [FromQuery] DateTime?startdate,
            [FromQuery] DateTime?enddate,
            [FromQuery] string sortColumn,
            [FromQuery] int sortType, [FromQuery] string search)
        {
            if (page == 0)
            {
                page = 1;
            }

            search = search == null ? string.Empty : HttpUtility.UrlDecode(search).Trim();

            if (enddate != null && enddate.HasValue)
            {
                enddate = enddate.Value.AddDays(1);
            }

            if (string.IsNullOrEmpty(sortColumn))
            {
                sortColumn = "date";
            }

            if (sortType == 0)
            {
                sortType = 2;
            }

            ViewBag.PageSize    = 50;
            ViewBag.CurrentPage = page;
            ViewBag.StartDate   = startdate;
            ViewBag.EndDate     = enddate;
            ViewBag.SortColumn  = sortColumn;
            ViewBag.SortType    = sortType;
            ViewBag.Search      = search;

            var apps = await _scanCenterAppointmentQuery.Get_CORPAllApppointment(page, (int)ViewBag.PageSize, search, startdate, enddate, sortColumn, sortType, true);

            return(View(apps.Item2));
        }
Exemplo n.º 2
0
        public async Task <FileContentResult> ScancenterAppointmentExport(
            [FromQuery] int page,
            [FromQuery] DateTime?startdate,
            [FromQuery] DateTime?enddate,
            [FromQuery] string sortColumn,
            [FromQuery] int sortType,
            [FromQuery] bool corp, [FromQuery] string search)
        {
            ViewBag.PageSize = 50;
            search           = search == null ? string.Empty : HttpUtility.UrlDecode(search).Trim();
            if (page == 0)
            {
                page = 1;
            }
            ViewBag.CurrentPage = page;
            ViewBag.StartDate   = startdate;
            ViewBag.EndDate     = enddate;
            ViewBag.Search      = search;

            if (enddate != null && enddate.HasValue)
            {
                enddate = enddate.Value.AddDays(1);
            }

            if (string.IsNullOrEmpty(sortColumn))
            {
                sortColumn = "date";
            }

            if (sortType == 0)
            {
                sortType = 2;
            }

            IList <ClientMotherResponseModel> apps = new List <ClientMotherResponseModel>();
            string header;

            if (corp)
            {
                (_, apps) = await _scanCenterAppointmentQuery.Get_CORPAllApppointment(page, (int)ViewBag.PageSize, search, startdate, enddate, sortColumn, sortType, true);

                header = @"First Name, Last Name, Email, Location, Phone, Due Date, DOB, REG DATE, Address, Apt, City, State, Zip,Name of Doctor or Hospital, Phone of Doctor or Hospital, Insurance, Interested in Breast Pump, Insurance Company, Insurance Id, Insurance Group, Custom Field" + System.Environment.NewLine;
            }
            else
            {
                (_, apps) = await _scanCenterAppointmentQuery.GetAllApppointment(GetLoggedinUser().Result.Id, page, (int)ViewBag.PageSize, search, startdate, enddate, sortColumn, sortType);

                header = $@"First Name, Last Name, Email, Phone, Due Date, DOB, REG DATE, Address, Apt, City, State, Zip,Name of Doctor or Hospital, Phone of Doctor or Hospital, Insurance, Interested in Breast Pump, Insurance Company, Insurance Id, Insurance Group, Custom Field" + System.Environment.NewLine;
            }
            StringBuilder csv = new StringBuilder();

            csv.Append(header);
            foreach (var s in apps)
            {
                List <OtherDetailResponseModel> od = Newtonsoft.Json.JsonConvert.DeserializeObject <List <OtherDetailResponseModel> >(s.OtherDetails);
                string ods = "";
                if (od != null && od.Any())
                {
                    foreach (var item in od)
                    {
                        ods = $"{ ods} Q: {item.Title}{Environment.NewLine} A: {item.Data}{Environment.NewLine}";
                    }
                }

                string mck = (!s.IsInsuranceRequired) ? "No" : "Yes";
                string bp  = (s.IsBreastPumpNeeded ? "Yes" : "No");
                string row;
                if (corp)
                {
                    row = String.Join(",",
                                      "\"" + s.FirstName + "\"",
                                      "\"" + s.LastName + "\"",
                                      "\"" + s.Email + "\"",
                                      "\"" + s.CompanyName + "\"",
                                      "\"" + s.Phone + "\"",
                                      "\"" + s.DueDate?.ToString("MM/dd/yyyy") + "\"",
                                      "\"" + s.DOB?.ToString("MM/dd/yyyy") + "\"",
                                      "\"" + s.CreatedDate.ToString("MM/dd/yyyy") + "\"",

                                      "\"" + s.Address + "\"",
                                      "\"" + s.Apt + "\"",
                                      "\"" + s.City + "\"",
                                      "\"" + s.State + "\"",
                                      "\"" + s.Zip + "\"",
                                      "\"" + s.DoctorName + "\"",
                                      "\"" + s.DoctorPhone + "\"",
                                      "\"" + mck + "\"",
                                      "\"" + bp + "\"",
                                      "\"" + s.InsuranceCompany + "\"",
                                      "\"" + s.InsuranceNumber + "\"",
                                      "\"" + s.InsuranceGroup + "\"",

                                      "\"" + ods + "\"");
                }
                else
                {
                    row = String.Join(",",
                                      "\"" + s.FirstName + "\"",
                                      "\"" + s.LastName + "\"",
                                      "\"" + s.Email + "\"",
                                      "\"" + s.Phone + "\"",
                                      "\"" + s.DueDate?.ToString("MM/dd/yyyy") + "\"",
                                      "\"" + s.DOB?.ToString("MM/dd/yyyy") + "\"",
                                      "\"" + s.CreatedDate.ToString("MM/dd/yyyy") + "\"",
                                      "\"" + s.Address + "\"",
                                      "\"" + s.Apt + "\"",
                                      "\"" + s.City + "\"",
                                      "\"" + s.State + "\"",
                                      "\"" + s.Zip + "\"",
                                      "\"" + s.DoctorName + "\"",
                                      "\"" + s.DoctorPhone + "\"",
                                      "\"" + mck + "\"",
                                      "\"" + bp + "\"",
                                      "\"" + s.InsuranceCompany + "\"",
                                      "\"" + s.InsuranceNumber + "\"",
                                      "\"" + s.InsuranceGroup + "\"",

                                      "\"" + ods + "\"");
                }

                csv.AppendLine(row);
            }

            FileContentResult csvFile = File(new UTF8Encoding().GetBytes(csv.ToString()), "text/csv", "Client.csv");

            return(csvFile);
        }