Exemplo n.º 1
0
        public ActionResult CenterEntry(Center aCenter)
        {
            List <District> districtList = headManager.GetDistrictList();
            List <Thana>    thanaList    = headManager.GetThanaList();

            ViewBag.DistrictList = districtList;
            ViewBag.ThanaList    = thanaList;

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

            bool doesCenterExits = headManager.IsCenterExist(aCenter);

            if (doesCenterExits)
            {
                ViewBag.SaveSuccessMsg = "Center Already Exsits";
            }
            else
            {
                List <string> codePassword = headManager.GeneratedCodeAndPassword(aCenter.DistrictId, aCenter.ThanaId);
                aCenter.Code     = codePassword[0];
                aCenter.Password = codePassword[1];
                if (headManager.SetCenter(aCenter))
                {
                    ViewBag.SaveSuccessMsg = "Successful. Center information saved.";
                    CenterPdf centerPdf = new CenterPdf()
                    {
                        CenterName   = aCenter.Name,
                        DistrictName = headManager.GetDistrictNameById(aCenter.DistrictId),
                        ThanaName    = headManager.GetThanaNameById(aCenter.ThanaId),
                        Code         = aCenter.Code,
                        Password     = aCenter.Password
                    };
                    Session["CenterPdf"]      = centerPdf;
                    Session["CenterOtherPdf"] = aCenter;
                    return(RedirectToAction("CenterInformation", centerPdf));
                }
                else
                {
                    ViewBag.SaveSuccessMsg = "Failed.";
                }
            }
            return(View());
        }
Exemplo n.º 2
0
        public ActionResult CenterInformation(CenterPdf newCenter)
        {
            if (newCenter == null)
            {
                newCenter = Session["CenterOtherPdf"] as CenterPdf;
            }
            Document document = new Document();

            MemoryStream stream = new MemoryStream();

            try
            {
                PdfWriter pdfWriter = PdfWriter.GetInstance(document, stream);
                pdfWriter.CloseStream = false;

                document.Open();
                document.Add(new Paragraph("Center Information"));
                document.Add(new Paragraph("Center Name: " + newCenter.CenterName));
                document.Add(new Paragraph("District : " + newCenter.DistrictName));
                document.Add(new Paragraph("Thana : " + newCenter.ThanaName));
                document.Add(new Paragraph("Code : " + newCenter.Code));
                document.Add(new Paragraph("Password : "******"application/pdf", "CenterInformation.pdf"));
        }