Exemplo n.º 1
0
        public FileStreamResult PrintPdf()
        {
            var outputDoc = new PdfDocument();

            outputDoc.Info.Title            = "NSNA-NE 2017 Directory";
            outputDoc.Info.Author           = "Karuppiah Ganesan";
            outputDoc.Info.CreationDate     = DateTime.Parse("01-01-2017");
            outputDoc.Info.ModificationDate = DateTime.Today;
            outputDoc.Info.Subject          = "NSNA-NE 2017 Directory";

            AddPdfPage(GetCoverPageHtml, outputDoc);

            var contacts = new ContactInfoDB().SelectAllFamilyInfo();

            foreach (var contact in contacts.OrderBy(i => i.FirstName))
            {
                AddPdfPage(() => GetContactInfoHtml(contact), outputDoc);
            }

            AddPdfPage(GetEndPageHtml, outputDoc);

            MemoryStream ms = new MemoryStream();

            outputDoc.Save(ms, false);
            return(new FileStreamResult(ms, "application/pdf"));
        }
Exemplo n.º 2
0
        public ActionResult List786()
        {
            ContactInfoDB contactInfoDB = new ContactInfoDB();
            var           allContacts   = contactInfoDB.SelectAllforList();

            return(View("List", allContacts));
        }
Exemplo n.º 3
0
        public ActionResult Create(ContactInfoViewModel model)
        {
            ValidateModel(model);

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            //Process Data to Create Data Model
            FamilyInfoDBModel familyContact = ProcessViewModeltoDBModel(model);

            //Insert into DB
            ContactInfoDB contactInfoDB = new ContactInfoDB();

            contactInfoDB.InsertFamilyInfo(familyContact);

            //Upload Pic to Azure.
            var familyPic = model.FamilyPic;

            if (familyPic != null && familyPic.ContentLength != 0 && !string.IsNullOrWhiteSpace(familyContact.FamilyPicFileName))
            {
                var mediaFileName = familyContact.FamilyPicFileName;
                new AzureFileStorage().UploadFile(mediaFileName, familyPic.InputStream);
            }

            //Send Email.
            GMailDispatcher mailDispatcher = new GMailDispatcher();

            mailDispatcher.SendCreateConfirmMsg(familyContact.Email, familyContact.FirstName + " " + familyContact.LastName, familyContact.FamilyContactGuid);

            return(View("CreateConfirm"));
        }
Exemplo n.º 4
0
        public ActionResult Edit(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(View("Error", new HandleErrorInfo(new Exception("Id is invalid."), "Directory", "Detail")));
            }

            ContactInfoDB     contactInfo       = new ContactInfoDB();
            FamilyInfoDBModel familyInfoDBModel = contactInfo.SelectWithKidsInfo(id);

            if (familyInfoDBModel == null || familyInfoDBModel.FamilyContactGuid == null)
            {
                return(View("Error", new HandleErrorInfo(new Exception("User Id not found."), "Directory", "Detail")));
            }
            else
            {
                ContactInfoViewModel viewModel = ProcessDBModeltoViewModel(familyInfoDBModel);
                if (viewModel == null)
                {
                    return(View("Error", new HandleErrorInfo(new Exception("Error Processing Data."), "Directory", "Detail")));
                }
                var kidsCount = (viewModel.Kids == null) ? 0 : viewModel.Kids.Count;
                //Fill in the rest of the Kids field with empty string for view
                for (int i = 0; i < (5 - kidsCount); i++)
                {
                    viewModel.Kids.Add(new KidsViewModel());
                }
                return(View(viewModel));
            }
        }
Exemplo n.º 5
0
        public ActionResult Detail(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(View("Error", new HandleErrorInfo(new Exception("Id is invalid."), "Directory", "Detail")));
            }

            ContactInfoDB     contactInfo       = new ContactInfoDB();
            FamilyInfoDBModel familyInfoDBModel = contactInfo.SelectWithKidsInfo(id);

            if (familyInfoDBModel == null || familyInfoDBModel.FamilyContactGuid == null)
            {
                return(View("Error", new HandleErrorInfo(new Exception("User Id not found."), "Directory", "Detail")));
            }
            else
            {
                ContactInfoViewModel viewModel = ProcessDBModeltoViewModel(familyInfoDBModel);
                if (viewModel == null)
                {
                    return(View("Error", new HandleErrorInfo(new Exception("Error Processing Data."), "Directory", "Detail")));
                }
                else
                {
                    return(View(viewModel));
                }
            }
        }
Exemplo n.º 6
0
        public ActionResult PdfPreview()
        {
            var contacts = new ContactInfoDB().SelectAllFamilyInfo();

            return(View(contacts));
        }