コード例 #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());
        }