public ActionResult EducationForm(EducationalBackground educationalBackground)
        {
            if (!ModelState.IsValid)
            {
                return(View(educationalBackground));
            }


            try
            {
                educationalBackground.UserId = HttpUtil.CurrentUser.UserId;

                var result = _eservice.Save(educationalBackground);

                if (result.HasError)
                {
                    ViewBag.Message = result.Message;
                    return(View("RegisterForm"));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(RedirectToAction("OwnerForm", "User"));
        }
 public EducationalBackgroundDtl(EducationalBackground edu)
 {
     if (edu != null)
     {
         edu.Convert <EducationalBackgroundDtl>(this);
     }
 }
Example #3
0
        public Result <EducationalBackground> Save(EducationalBackground userinfo)
        {
            var result = new Result <EducationalBackground>();

            try
            {
                var objtosave = _context.educationalBackgrounds.FirstOrDefault(u => u.UserId == userinfo.UserId);
                if (objtosave == null)
                {
                    objtosave = new EducationalBackground();
                    _context.educationalBackgrounds.Add(objtosave);
                }
                objtosave.School          = userinfo.School;
                objtosave.Collage         = userinfo.Collage;
                objtosave.UniversityPost  = userinfo.UniversityPost;
                objtosave.UniversityUnder = userinfo.UniversityUnder;
                objtosave.Others          = userinfo.Others;
                objtosave.UserId          = userinfo.UserId;


                if (!IsValid(objtosave, result))
                {
                    return(result);
                }
                _context.SaveChanges();
            }
            catch (Exception ex)
            {
                result.HasError = true;
                result.Message  = ex.Message;
            }
            return(result);
        }
Example #4
0
        private static InstructorApplication BuildNewInstructorApplication(
            InstructorApplicationViewModel applicationFromView, Student thisUser)
        {
            var educationList = new List <EducationalBackground>();

            foreach (EducationalBackGround educate in applicationFromView.EducationalBackgrounds)
            {
                var education = new EducationalBackground
                {
                    YearReceived        = educate.YearReceived,
                    Degree              = educate.Degree,
                    AreaOfStudy         = educate.AreaOfStudy,
                    UniversityOrCollege = educate.UniversityOrCollege
                };
                educationList.Add(education);
            }
            var instructorApplication = new InstructorApplication
            {
                StudentID             = thisUser.StudentID,
                EducationalBackground = new List <EducationalBackground>(),
                Experience            = applicationFromView.Experience,
                WillingToTravel       = applicationFromView.WillingToTravel,
                Approved = false
            };

            instructorApplication.EducationalBackground.AddRange(educationList);
            return(instructorApplication);
        }
 private void CollectEducationInfo()
 {
     _TheEmployeeToComplete.EmployeeDetails.Education.Major = _ItsView.Major;
     if (!string.IsNullOrEmpty(_ItsView.GraduateDate))
     {
         _TheEmployeeToComplete.EmployeeDetails.Education.GraduateTime = DateTime.Parse(_ItsView.GraduateDate);
     }
     _TheEmployeeToComplete.EmployeeDetails.Education.School = _ItsView.School;
     _TheEmployeeToComplete.EmployeeDetails.Education.EducationalBackground =
         EducationalBackground.GetById(int.Parse(_ItsView.EducationalBackground));
 }
Example #6
0
        public HttpResponseMessage GetListData(
            string keyword          = "",
            string educationalLevel = "",
            string cancelledStatus  = "",
            string sortOrderBy      = "",
            string sortExpression   = ""
            )
        {
            DataTable dt = EducationalBackground.GetListData(keyword, educationalLevel, cancelledStatus, sortOrderBy, sortExpression).Tables[0];

            return(Request.CreateResponse(HttpStatusCode.OK, iUtil.APIResponse.GetData(dt)));
        }
Example #7
0
        public string DeleteEducation(Guid id = new Guid())
        {
            try {
                Response.ContentType = "application/json";

                EducationalBackground edu = new EducationalBackground();
                edu.id = id;
                edu.Delete();

                return "";

            } catch (Exception e) {
                return e.Message;
            }
        }
Example #8
0
        public ActionResult EducationForm(EducationalBackground educationalBackground)
        {
            try
            {
                var result = eduDao.Save(educationalBackground);

                if (result.HasError)
                {
                    ViewBag.Message = result.Message;
                    return(View("RegisterForm", educationalBackground));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(RedirectToAction("OwnerForm", "User"));
        }
Example #9
0
        public ActionResult Delete(int id)
        {
            var repo = Ioc.Get <IEducationalBackgroundRepository>();
            EducationalBackground edu = repo.GetById(id);

            if (edu != null)
            {
                repo.Delete(id);
                TempData[notificationSuccess] = string.Format("'{0}' was successfully deleted.", edu.Name);
                string returnUrl = Url.Action("profile", "employee", new { id = edu.EmployeeId }) + "#edu-background";
                return(Redirect(returnUrl));
            }
            else
            {
                TempData[notificationWarning] = "Oops, the Educational Background you wanted to delete no longer exists.";
                return(RedirectToAction("index", "employee"));
            }
        }
Example #10
0
        public ActionResult Create(EducationalBackgroundDtl edu)
        {
            string returnUrl = Url.Action("profile", "employee", new { id = edu.EmployeeId }) + "#edu-background";

            if (ModelState.IsValid)
            {
                EducationalBackground eduback = edu.ToModel();
                var repo = Ioc.Get <IEducationalBackgroundRepository>();
                repo.Create(eduback);

                TempData[notificationSuccess] = "New Education Background successfully created.";
            }
            else
            {
                TempData[notificationError] = "Be sure to input the required fields and in proper format.";
            }

            return(Redirect(returnUrl));
        }
Example #11
0
        /// <summary>
        /// 除了image以外的所有数据绑定
        /// </summary>
        /// <param name="sdr"></param>
        /// <param name="employee"></param>
        private static void GetEmployeeNotImageFieldFromParm(SqlDataReader sdr, Employee employee)
        {
            for (int i = 0; i < sdr.FieldCount; i++)
            {
                DateTime tryDateTimeParse;
                int      tryIntParse;
                bool     tryBoolParse;
                switch (sdr.GetName(i))
                {
                case _DBAccountID:
                    if (sdr[_DBAccountID] != null && int.TryParse(sdr[_DBAccountID].ToString(), out tryIntParse))
                    {
                        employee.Account                   = employee.Account ?? new Account();
                        employee.Account.Id                = (int)sdr[_DBAccountID];
                        employee.Account.Position          = new Position();
                        employee.Account.Position.Grade    = new PositionGrade();
                        employee.Account.Position.Grade.Id = (int)sdr[_DBPositionGradeID];
                    }
                    break;

                case _DBCompanyID:
                    if (sdr[_DBCompanyID] != null && int.TryParse(sdr[_DBCompanyID].ToString(), out tryIntParse))
                    {
                        employee.EmployeeDetails              = employee.EmployeeDetails ?? new EmployeeDetails();
                        employee.EmployeeDetails.Work         = employee.EmployeeDetails.Work ?? new Work();
                        employee.EmployeeDetails.Work.Company =
                            employee.EmployeeDetails.Work.Company ?? new Department();
                        employee.EmployeeDetails.Work.Company.DepartmentID = (int)sdr[_DBCompanyID];
                    }
                    break;

                case _DBEmployeeType:
                    if (sdr[_DBEmployeeType] != null &&
                        int.TryParse(sdr[_DBEmployeeType].ToString(), out tryIntParse))
                    {
                        employee.EmployeeType = (EmployeeTypeEnum)sdr[_DBEmployeeType];
                    }
                    break;

                case _DBComeDate:
                    if (sdr[_DBComeDate] != null &&
                        DateTime.TryParse(sdr[_DBComeDate].ToString(), out tryDateTimeParse))
                    {
                        employee.EmployeeDetails               = employee.EmployeeDetails ?? new EmployeeDetails();
                        employee.EmployeeDetails.Work          = employee.EmployeeDetails.Work ?? new Work();
                        employee.EmployeeDetails.Work.ComeDate = (DateTime)sdr[_DBComeDate];
                    }
                    break;

                case _DBLeaveDate:
                    if (sdr[_DBLeaveDate] != null &&
                        DateTime.TryParse(sdr[_DBLeaveDate].ToString(), out tryDateTimeParse))
                    {
                        employee.EmployeeDetails      = employee.EmployeeDetails ?? new EmployeeDetails();
                        employee.EmployeeDetails.Work = employee.EmployeeDetails.Work ?? new Work();
                        employee.EmployeeDetails.Work.DimissionInfo = employee.EmployeeDetails.Work.DimissionInfo ??
                                                                      new DimissionInfo();
                        employee.EmployeeDetails.Work.DimissionInfo.DimissionDate = (DateTime)sdr[_DBLeaveDate];
                    }
                    break;

                case _DBBirthday:
                    if (sdr[_DBBirthday] != null &&
                        DateTime.TryParse(sdr[_DBBirthday].ToString(), out tryDateTimeParse))
                    {
                        employee.EmployeeDetails          = employee.EmployeeDetails ?? new EmployeeDetails();
                        employee.EmployeeDetails.Birthday = (DateTime)sdr[_DBBirthday];
                    }
                    break;

                case _DBResidencePermit:
                    if (sdr[_DBResidencePermit] != null &&
                        DateTime.TryParse(sdr[_DBResidencePermit].ToString(), out tryDateTimeParse))
                    {
                        employee.EmployeeDetails = employee.EmployeeDetails ?? new EmployeeDetails();
                        employee.EmployeeDetails.ResidencePermits = employee.EmployeeDetails.ResidencePermits ??
                                                                    new ResidencePermit();
                        employee.EmployeeDetails.ResidencePermits.DueDate = (DateTime)sdr[_DBResidencePermit];
                    }
                    break;

                case _DBEnglishName:
                    if (sdr[_DBEnglishName] != null)
                    {
                        employee.EmployeeDetails = employee.EmployeeDetails ?? new EmployeeDetails();

                        employee.EmployeeDetails.EnglishName = sdr[_DBEnglishName].ToString();
                    }
                    break;

                case _DBGender:
                    if (sdr[_DBGender] != null && int.TryParse(sdr[_DBGender].ToString(), out tryIntParse))
                    {
                        employee.EmployeeDetails        = employee.EmployeeDetails ?? new EmployeeDetails();
                        employee.EmployeeDetails.Gender = Gender.GetById((int)sdr[_DBGender]);
                    }
                    break;

                case _DBPoliticalAffiliation:
                    if (sdr[_DBPoliticalAffiliation] != null &&
                        int.TryParse(sdr[_DBPoliticalAffiliation].ToString(), out tryIntParse))
                    {
                        employee.EmployeeDetails = employee.EmployeeDetails ?? new EmployeeDetails();
                        employee.EmployeeDetails.PoliticalAffiliation =
                            PoliticalAffiliation.GetById((int)sdr[_DBPoliticalAffiliation]);
                    }
                    break;

                case _DBMaritalStatus:
                    if (sdr[_DBMaritalStatus] != null &&
                        int.TryParse(sdr[_DBMaritalStatus].ToString(), out tryIntParse))
                    {
                        employee.EmployeeDetails = employee.EmployeeDetails ?? new EmployeeDetails();
                        employee.EmployeeDetails.MaritalStatus = MaritalStatus.GetById((int)sdr[_DBMaritalStatus]);
                    }
                    break;

                case _DBEducationalBackground:
                    if (sdr[_DBEducationalBackground] != null &&
                        int.TryParse(sdr[_DBEducationalBackground].ToString(), out tryIntParse))
                    {
                        employee.EmployeeDetails           = employee.EmployeeDetails ?? new EmployeeDetails();
                        employee.EmployeeDetails.Education = employee.EmployeeDetails.Education ?? new Education();
                        employee.EmployeeDetails.Education.EducationalBackground =
                            EducationalBackground.GetById((int)sdr[_DBEducationalBackground]);
                    }
                    break;

                case _DBWorkType:
                    if (sdr[_DBWorkType] != null && int.TryParse(sdr[_DBWorkType].ToString(), out tryIntParse))
                    {
                        employee.EmployeeDetails               = employee.EmployeeDetails ?? new EmployeeDetails();
                        employee.EmployeeDetails.Work          = employee.EmployeeDetails.Work ?? new Work();
                        employee.EmployeeDetails.Work.WorkType = WorkType.GetById((int)sdr[_DBWorkType]);
                    }
                    break;

                case _DBHasChild:
                    if (sdr[_DBHasChild] != null && bool.TryParse(sdr[_DBHasChild].ToString(), out tryBoolParse))
                    {
                        employee.EmployeeDetails                 = employee.EmployeeDetails ?? new EmployeeDetails();
                        employee.EmployeeDetails.Family          = employee.EmployeeDetails.Family ?? new Family();
                        employee.EmployeeDetails.Family.HasChild = (bool)sdr[_DBHasChild];
                    }
                    break;

                case _DBCertificates:
                    if (sdr[_DBCertificates] != null)
                    {
                        employee.EmployeeDetails           = employee.EmployeeDetails ?? new EmployeeDetails();
                        employee.EmployeeDetails.Education = employee.EmployeeDetails.Education ?? new Education();
                        employee.EmployeeDetails.Education.Certificates = sdr[_DBCertificates].ToString();
                    }
                    break;

                case _DBPRPArea:
                    if (sdr[_DBPRPArea] != null)
                    {
                        employee.EmployeeDetails = employee.EmployeeDetails ?? new EmployeeDetails();
                        employee.EmployeeDetails.RegisteredPermanentResidence =
                            employee.EmployeeDetails.RegisteredPermanentResidence ??
                            new RegisteredPermanentResidence();
                        employee.EmployeeDetails.RegisteredPermanentResidence.PRPArea = sdr[_DBPRPArea].ToString();
                    }
                    break;

                case _DBProbationTime:
                    if (sdr[_DBProbationTime] != null &&
                        DateTime.TryParse(sdr[_DBProbationTime].ToString(), out tryDateTimeParse))
                    {
                        employee.EmployeeDetails = employee.EmployeeDetails ?? new EmployeeDetails();
                        employee.EmployeeDetails.ProbationTime = (DateTime)sdr[_DBProbationTime];
                    }
                    break;

                case _DBProbationStartTime:
                    if (sdr[_DBProbationStartTime] != null &&
                        DateTime.TryParse(sdr[_DBProbationStartTime].ToString(), out tryDateTimeParse))
                    {
                        employee.EmployeeDetails = employee.EmployeeDetails ?? new EmployeeDetails();
                        employee.EmployeeDetails.ProbationStartTime = (DateTime)sdr[_DBProbationStartTime];
                    }
                    break;

                case _DBDoorCardNo:
                    if (sdr[_DBDoorCardNo] != null)
                    {
                        employee.EmployeeAttendance            = employee.EmployeeAttendance ?? new EmployeeAttendance();
                        employee.EmployeeAttendance.DoorCardNo = sdr[_DBDoorCardNo].ToString();
                    }
                    break;

                case _DBSocietyWorkAge:
                    if (sdr[_DBSocietyWorkAge] != null &&
                        int.TryParse(sdr[_DBSocietyWorkAge].ToString(), out tryIntParse))
                    {
                        employee.SocWorkAgeAndVacationList = employee.SocWorkAgeAndVacationList ??
                                                             new SocWorkAgeAndVacationList();
                        employee.SocWorkAgeAndVacationList.SocietyWorkAge = (int)sdr[_DBSocietyWorkAge];
                    }
                    break;

                case _DBCountryNationalityID:
                    if (sdr[_DBCountryNationalityID] != null &&
                        int.TryParse(sdr[_DBCountryNationalityID].ToString(), out tryIntParse))
                    {
                        employee.EmployeeDetails.CountryNationality =
                            new Nationality((int)sdr[_DBCountryNationalityID], "", "");
                    }
                    break;

                case _DBWorkPlace:
                    employee.EmployeeDetails.Work           = employee.EmployeeDetails.Work ?? new Work();
                    employee.EmployeeDetails.Work.WorkPlace = sdr[_DBWorkPlace].ToString();
                    break;

                case _DBPrincipalShipID:
                    if (sdr[_DBPrincipalShipID] != null &&
                        int.TryParse(sdr[_DBPrincipalShipID].ToString(), out tryIntParse))
                    {
                        employee.EmployeeDetails.Work = employee.EmployeeDetails.Work ?? new Work();
                        employee.EmployeeDetails.Work.Principalship = PrincipalShip.GetById((
                                                                                                int)
                                                                                            sdr[_DBPrincipalShipID]);
                    }
                    break;

                case _DBSalaryCardNo:
                    employee.EmployeeDetails.Work = employee.EmployeeDetails.Work ?? new Work();
                    employee.EmployeeDetails.Work.SalaryCardNo = sdr[_DBSalaryCardNo].ToString();
                    break;

                case _DBSalaryCardBank:
                    employee.EmployeeDetails.Work = employee.EmployeeDetails.Work ?? new Work();
                    employee.EmployeeDetails.Work.SalaryCardBank = sdr[_DBSalaryCardBank].ToString();
                    break;

                default:
                    break;
                }
            }
        }
Example #12
0
        public string SaveEducation(string edu = "")
        {
            try {
                Response.ContentType = "application/json";
                // Instantiate EducationalBackground object
                EducationalBackground education = new EducationalBackground();
                education = JsonConvert.DeserializeObject<EducationalBackground>(edu);
                if (education.id == Guid.Empty) {
                    education.id = Guid.NewGuid();
                }

                // Save object
                education.Save();

                string desc = education.ParseNameLocation();
                education.description = desc;

                string json = JsonConvert.SerializeObject(education, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
                education.json = json;

                // Serialize saved object and return
                return JsonConvert.SerializeObject(education, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });

            } catch (Exception e) {
                return e.Message;
            }
        }
Example #13
0
 public bool IsValid(EducationalBackground obj, Result <EducationalBackground> result)
 {
     return(true);
 }