// GET: Conferences/VPCConfigure/5
        //  Virtual Payment Client (VPC) on credit card
        public ActionResult VPCConfigure(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Conference conference = db.Conferences.Find(id);

            if (conference == null)
            {
                return(HttpNotFound());
            }
            ;
            if (conference.DateClose != null)
            {
                return(RedirectToAction("Details", "Conferences", new { id = conference.ID }));
            }

            ViewModel_ConferenceVPC viewModel_ConferenceVPC = new ViewModel_ConferenceVPC();

            viewModel_ConferenceVPC.Confernece = conference;

            //  Select persentation type
            List <ConfigureVPC> ConfigureVPCs = db.ConfigureVPCs.Where(p => p.ConferenceID == conference.ID).OrderBy(p => p.Explanation).ToList();

            viewModel_ConferenceVPC.ConfigureVPCs = ConfigureVPCs;

            return(View(viewModel_ConferenceVPC));
        }
        public ActionResult VPCConfirmed(ViewModel_ConferenceVPC viewModel_ConferenceVPC)
        {
            if (viewModel_ConferenceVPC == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            if (viewModel_ConferenceVPC.Confernece == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            if (viewModel_ConferenceVPC.Confernece.ID == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            if (!ModelState.IsValid)
            {
                ViewData["error"] = "Please check below item(s), again";
                return(View(viewModel_ConferenceVPC));
            }
            //  Save
            //  Procedure of form edition
            Cmn cmn = new Cmn();

            cmn.UserName = "******";
            if (User.Identity.IsAuthenticated)
            {
                cmn.UserName = User.Identity.Name;
            }
            Conference conference = db.Conferences.Find(viewModel_ConferenceVPC.Confernece.ID);

            //  Save as VPC
            if (viewModel_ConferenceVPC.ConfigureVPCs != null)
            {
                foreach (ConfigureVPC item in viewModel_ConferenceVPC.ConfigureVPCs)
                {
                    ConfigureVPC configureVPC = db.ConfigureVPCs.Find(item.ID);
                    // ***  Non-system attribute (Begin)    *** //
                    configureVPC.Unit        = item.Unit;
                    configureVPC.Title       = item.Title;
                    configureVPC.Explanation = item.Explanation;
                    configureVPC.Name        = item.Name;
                    configureVPC.Value       = item.Value;
                    // ***  Non-system attribute (Finish)   *** //
                    //  Set system log
                    configureVPC.DateEdit        = cmn.CurrentDatetime;
                    configureVPC.UserEdit        = cmn.UserName;
                    db.Entry(configureVPC).State = EntityState.Modified;
                }
            }
            //  Update database
            db.SaveChanges();
            String ctrlBtn = Request.Form["ctrlBtn"];

            if (ctrlBtn == "Refresh")
            {
                return(RedirectToAction("VPCConfigure", "Conferences", new { id = conference.ID }));
            }
            if (ctrlBtn == "Submit")
            {
                return(RedirectToAction("Details", "Conferences", new { id = conference.ID }));
            }
            return(RedirectToAction("", "Home", null));
        }