public ActionResult Delete(InsteadDeportationsViewModel InsteadDeportationVM)
        {
            InsteadDeportationsBLL InsteadDeportationsBLL = new InsteadDeportationsBLL();

            InsteadDeportationsBLL.LoginIdentity = UserIdentity;
            InsteadDeportationsBLL.Remove(InsteadDeportationVM.InsteadDeportationID);
            return(RedirectToAction("Index"));
        }
        private InsteadDeportationsViewModel GetByInsteadDeportationID(int id)
        {
            InsteadDeportationsBLL       InsteadDeportationBLL = (new InsteadDeportationsBLL()).GetByInsteadDeportationID(id);
            InsteadDeportationsViewModel InsteadDeportationVM  = new InsteadDeportationsViewModel();

            if (InsteadDeportationBLL != null)
            {
                InsteadDeportationVM.InsteadDeportationID   = InsteadDeportationBLL.InsteadDeportationID;
                InsteadDeportationVM.DeportationDate        = InsteadDeportationBLL.DeportationDate.Date;
                InsteadDeportationVM.EmployeeCareersHistory = InsteadDeportationBLL.EmployeeCareerHistory;
                InsteadDeportationVM.Note        = InsteadDeportationBLL.Note;
                InsteadDeportationVM.Amount      = InsteadDeportationBLL.Amount;
                InsteadDeportationVM.CreatedDate = InsteadDeportationBLL.CreatedDate;
                InsteadDeportationVM.CreatedBy   = InsteadDeportationVM.GetCreatedByDisplayed(InsteadDeportationBLL.CreatedBy);
            }
            return(InsteadDeportationVM);
        }
        public ActionResult Create(InsteadDeportationsViewModel InsteadDeportationVM)
        {
            InsteadDeportationsBLL InsteadDeportation = new InsteadDeportationsBLL();

            InsteadDeportation.DeportationDate       = InsteadDeportationVM.DeportationDate;
            InsteadDeportation.Note                  = InsteadDeportationVM.Note;
            InsteadDeportation.Amount                = InsteadDeportationVM.Amount;
            InsteadDeportation.EmployeeCareerHistory = new EmployeesCareersHistoryBLL()
            {
                EmployeeCareerHistoryID = (int)InsteadDeportationVM.EmployeeCareerHistoryID
            };
            InsteadDeportation.LoginIdentity = new EmployeesCodesBLL()
            {
                EmployeeCodeID = int.Parse(Session["EmployeeCodeID"].ToString())
            };
            Result result = InsteadDeportation.Add();

            if ((System.Type)result.EnumType == typeof(AllowanceValidationEnum))
            {
                InsteadDeportationsBLL InsteadDeportationEntity = (InsteadDeportationsBLL)result.Entity;
                if (result.EnumMember == AllowanceValidationEnum.Done.ToString())
                {
                    // Session["InsteadDeportationID"] = ((InsteadDeportationsBLL)result.Entity).InsteadDeportationID;
                    InsteadDeportationVM.InsteadDeportationID = ((InsteadDeportationsBLL)result.Entity).InsteadDeportationID;
                }
                else if (result.EnumMember == AllowanceValidationEnum.RejectedBecauseOfNotAllowedForJob.ToString())     //not in jobAllowance table
                {
                    throw new CustomException(Resources.Globalization.ValidationAllowanceNotAllowedForJobText);
                }
                else if (result.EnumMember == AllowanceValidationEnum.RejectedBecauseOfStoped.ToString())               //allowance inactive
                {
                    throw new CustomException(Resources.Globalization.ValidationAllowanceStopedText);
                }
                else if (result.EnumMember == AllowanceValidationEnum.RejectedBecauseOfStopedForJob.ToString())     // job inactive
                {
                    throw new CustomException(Resources.Globalization.ValidationAllowanceStopedForJobText);
                }
            }

            //return View(InsteadDeportationVM);
            return(Json(new { InsteadDeportationID = InsteadDeportationVM.InsteadDeportationID }, JsonRequestBehavior.AllowGet));
        }