Ejemplo n.º 1
0
        public ViewResult Profession()
        {
            CurrentPage = PageTypes.ProfSearch;
            var model = new ProfessionalSearchVm();

            model.ApplyFilters();
            model.FilteredItems = new List <User>();
            return(View(Routes.ControllerIndex, model));
        }
Ejemplo n.º 2
0
        public ActionResult Profession(ProfessionalSearchVm model, string output)
        {
            CurrentPage = PageTypes.ProfSearch;
            model.ApplyFilters(Request.Form);
            if (output == "excel")
            {
                StringBuilder csvData = new StringBuilder();
                csvData.AppendLine(("Name,Batch,Course,Degree,Mobile,Email"));
                foreach (var item in model.FilteredItems)
                {
                    var uc = item.UserCourses.Any() ? item.UserCourses[0] : new UserCourse {
                        Batch = "--", BranchName = "--", CourseName = "--"
                    };
                    csvData.AppendLine(string.Format("{0},{1},{2},{3},{4},{5}", item.FullName, uc.Batch, uc.BranchName, uc.CourseName, item.MobileNumber, item.Email));
                }
                var byteArray = Encoding.ASCII.GetBytes(csvData.ToString());
                var stream    = new MemoryStream(byteArray);
                return(File(stream, "text/plain", "NITCAA_ProfDetails_" + DateTime.Now.ToString("MMM_dd") + ".csv"));
            }

            return(View(Routes.ControllerIndex, model));
        }