示例#1
0
        // step 1

        public ActionResult Step1(string guidid)
        {
            if (!db.Inductions.Where(x => x.GuidId == guidid).Any())
            {
                return(RedirectToAction("index"));
            }

            var induction = db.Inductions.Where(x => x.GuidId == guidid).FirstOrDefault();

            IEnumerable <SelectListItem> countries = db.Countries.Where(x => x.Active == true && x.Deleted == false).OrderBy(x => x.Name).ToList().Select(x => new SelectListItem()
            {
                Text     = x.Name,
                Value    = x.Id.ToString(),
                Selected = false,
            });

            ViewBag.Countries = countries;

            var viewModel = new InductionStep1ViewModel
            {
                Id     = induction.Id,
                GuidId = induction.GuidId,
                //
                FullName              = induction.FullName,
                MobileNumber          = induction.MobileNumber,
                Email                 = induction.Email,
                NextOfKinName         = induction.NextOfKinName,
                NextOfKinRelationship = induction.NextOfKinRelationship,
                NextOfKinMobile       = induction.NextOfKinMobile,
                Address               = induction.Address,
                City     = induction.City,
                County   = induction.County,
                Postcode = induction.Postcode,
                Country  = induction.Country,
                //
                Step1Signature  = induction.Step1Signature,
                Step1DateSigned = induction.Step1DateSigned
            };

            if (viewModel == null)
            {
                return(HttpNotFound());
            }

            return(View(viewModel));
        }
示例#2
0
        public ActionResult Step1(InductionStep1ViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var induction = db.Inductions.Where(x => x.Id == viewModel.Id).FirstOrDefault();

                    // db
                    induction.FullName              = viewModel.FullName;
                    induction.MobileNumber          = viewModel.MobileNumber;
                    induction.Email                 = viewModel.Email;
                    induction.NextOfKinName         = viewModel.NextOfKinName;
                    induction.NextOfKinRelationship = viewModel.NextOfKinRelationship;
                    induction.NextOfKinMobile       = viewModel.NextOfKinMobile;
                    induction.Address               = viewModel.Address;
                    induction.City     = viewModel.City;
                    induction.County   = viewModel.County;
                    induction.Postcode = viewModel.Postcode;
                    induction.Country  = viewModel.Country;
                    //
                    induction.Step1Signature  = viewModel.Step1Signature;
                    induction.Step1DateSigned = viewModel.Step1DateSigned;
                    db.SaveChanges();

                    // log
                    Helpers.Logging.LogEntry("Induction: Step1 - InductionId: " + viewModel.Id, "", false);

                    return(RedirectToAction("step2", new { guidid = viewModel.GuidId }));
                }
                catch (Exception ex)
                {
                    // log
                    Helpers.Logging.LogEntry("Induction: Step1 - InductionId: " + viewModel.Id, ex.Message, true);
                }
            }

            return(View());
        }