public ActionResult SetupContractChangeForm([Bind(Include = "ID ,NewLastName, NewEmail, NewAddress, NewCity," +
                                                                    "NewState,NewZipcode,NewCountry,NewHomePhone, FormType, StatusID, EmployeeID, File")] EmployeeContractChanges contract, string FormType, HttpPostedFileBase File)
        {//called to either initiate a contract change request (during surveys) or HR editing a contract change form.
            EmployeeContractChangesRepository eCCR = new EmployeeContractChangesRepository();

            string form                = FormType;
            bool   editing             = form.Contains("editing");
            bool   survey              = form.Contains("survey");
            bool   optout              = form.Contains("optout");
            bool   notEditingCurrentCF = false;
            int    UserID              = -1;

            if (form == "editing")
            {
                UserID = contract.EmployeeID;
            }
            else
            {
                UserID = ((CustomAuthentication.CustomPrincipal) this.HttpContext.User).ID;
            }



            EmployeeContractChanges LastCF = eCCR.GetLCF(UserID);

            if (editing)
            {
                if (LastCF != null)
                {
                    notEditingCurrentCF = (contract.ID != eCCR.GetLCF(UserID).ID) ? true : false;
                }

                if (notEditingCurrentCF)
                {
                    ModelState.AddModelError("", "Recent changes have been made to this Contract, please review these changes.");
                    HRDashboardViewModel passBackContract = eCCR.HRDashboardViewModel(contract, form);
                    passBackContract.ContractChanges = new List <ContractChanges>();
                    IEnumerable <FormStatus> Statuses = new List <FormStatus>();

                    using (AuthenticateContext db = new AuthenticateContext())
                    {
                        Statuses = db.FormStatuses.AsEnumerable().ToList();
                    }
                    ViewBag.FormStatuses = new SelectList(Statuses, "ID", "StatusName");
                    ViewBag.Error        = "Recent changes have been made to this Contract, please review these changes";
                    //return PartialView("~/Views/HR/SetupContractChangeForm.cshtml", passBackContract);
                    var errors = new Hashtable();
                    foreach (var pair in ModelState)
                    {
                        if (pair.Value.Errors.Count > 0)
                        {
                            errors[pair.Key] = pair.Value.Errors.Select(error => error.ErrorMessage).ToList();
                        }
                    }
                    return(Json(new { success = true, errors }));
                }
            }



            if (survey || editing)
            {
                eCCR.InsertEmployeeContractChanges(contract, UserID, editing, survey);
                if (editing)
                {
                    eCCR.CheckApproved(contract, UserID);

                    return(Json(new { redirectTo = Url.Action("EnableSurvey", "FormUpdates") }));
                }
            }
            else if (optout)
            {
                eCCR.ResetContractChange(UserID, contract);
                //return Json(new { redirectTo = Url.Action("EnableSurvey", "FormUpdates") });
                return(RedirectToAction("EnableSurvey", "FormUpdates"));
            }
            //Need to send to Form updater method that goes through to determine if user needs to get Surveyed.
            return(RedirectToAction("EnableSurvey", "FormUpdates"));
        }
 public ActionResult ShowOptOutForm(EmployeeContractChanges contract)
 {
     return(PartialView("SetupOptOutForm", contract));
 }