Exemple #1
0
        public JsonResult SaveEmployeeUser(User EmployeeUser, Int32 employeeId)
        {
            JsonResult result = null;

            if (EmployeeUser != null)
            {
                try
                {
                    if (EmployeeUser.Id > 0)
                    {
                        User           _user           = EmployeeUser;
                        EmployeeHeader _employeeHeader = EmployeeProfileService.GetEmployeeProfileDetailsById(employeeId);
                        _user.ModifiedOn = _employeeHeader.ModifiedOn = DateTimeConverter.SingaporeDateTimeConversion(DateTime.Now);
                        _user.ModifiedBy = _employeeHeader.ModifiedBy = USER_OBJECT.UserID;
                        _user.UserName   = _employeeHeader.UserEmailId = EmployeeUser.UserName;
                        _user.Password   = _employeeHeader.Password = _employeeHeader.ConfirmPassword = EmployeeUser.Password;

                        LogInLogOutService.Save(EmployeeUser, true);
                        EmployeeProfileService.SaveEmployeeProfile(_employeeHeader, true);

                        result = Json(new { sucess = true, message = C.SUCCESSFUL_SAVE_MESSAGE }, JsonRequestBehavior.AllowGet);
                    }
                }
                catch (Exception ex)
                {
                    if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message))
                    {
                        return(Json(new { success = false, message = ex.InnerException.Message }, JsonRequestBehavior.DenyGet));
                    }
                }
            }
            return(result);
        }
Exemple #2
0
        public JsonResult GetEmployeeById(int employeeId, bool IsfromIndividualEmployee)
        {
            JsonResult result = null;

            try
            {
                EmployeeHeader     employeeHeader     = null;
                string             imagePathName      = string.Empty;
                LookUpDescriptions lookUpDescriptions = null;
                if (!IsfromIndividualEmployee)
                {
                    employeeHeader = EmployeeProfileService.GetEmployeeProfileDetailsById(employeeId);
                }
                else if (employeeId == 0)
                {
                    employeeHeader = EmployeeProfileService.GetEmployeeProfileList <EmployeeHeader>(e => e.UserId == USER_OBJECT.Id).FirstOrDefault();
                    EmployeeDocument employeeDocument = EmployeeProfileService.GetEmployeeDocuments <EmployeeDocument>(ed => ed.EmployeeHeaderId == employeeHeader.Id).FirstOrDefault();
                    if (employeeDocument != null)
                    {
                        imagePathName = employeeDocument.FileName;
                    }
                    lookUpDescriptions = new LookUpDescriptions();
                    foreach (var employeePersonalInfo in employeeHeader.EmployeePersonalInfo)
                    {
                        lookUpDescriptions.MarriedStatus = LookUpCodeService.GetLookUpType(employeePersonalInfo.MaritalStatus).LookUpCode;
                    }
                    foreach (var employeeWorkDetail in employeeHeader.EmployeeWorkDetail)
                    {
                        lookUpDescriptions.Designation = LookUpCodeService.GetLookUpType(employeeWorkDetail.DesignationId.Value).LookUpCode;
                        lookUpDescriptions.Department  = LookUpCodeService.GetLookUpType(employeeWorkDetail.DepartmentId.Value).LookUpCode;
                    }

                    lookUpDescriptions.Country     = CompanyService.GetCountries <Country>(c => c.CountryCode == employeeHeader.Address.FirstOrDefault().CountryCode).FirstOrDefault().CountryName;
                    lookUpDescriptions.Nationality = CompanyService.GetCountries <Country>(c => c.CountryCode == employeeHeader.Nationality).FirstOrDefault().CountryName;
                }

                List <EmployeeDocument> employeeDocuments = EmployeeProfileService.GetEmployeeDocuments <EmployeeDocument>(e => e.EmployeeHeaderId == employeeHeader.Id).ToList();
                employeeHeader.EmployeeDocument = employeeDocuments != null ? employeeDocuments : null;

                result = Json(new { employeeHeader = employeeHeader, imagePathName = imagePathName, LookUpDescriptions = lookUpDescriptions }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message))
                {
                    return(Json(new { success = false, message = ex.InnerException.Message }, JsonRequestBehavior.DenyGet));
                }
            }

            return(result);
        }
Exemple #3
0
        private EmployeeHeader PrepareEmployeeHeader(EmployeeHeader employeeHeader, HttpFileCollection hfc = null, List <EmployeeDocumentViewModel> employeeDocumentViewModel = null)
        {
            EmployeeHeader _employeeHeader = null;

            if (employeeHeader.Id > 0)
            {
                _employeeHeader            = EmployeeProfileService.GetEmployeeProfileDetailsById(employeeHeader.Id);
                _employeeHeader.ModifiedBy = USER_OBJECT.UserName;
                _employeeHeader.ModifiedOn = DateTimeConverter.SingaporeDateTimeConversion(DateTime.Now);
            }
            else
            {
                _employeeHeader           = new EmployeeHeader();
                _employeeHeader.CreatedBy = USER_OBJECT.UserName;
                _employeeHeader.CreatedOn = DateTimeConverter.SingaporeDateTimeConversion(DateTime.Now);
            }
            EmployeePersonalInfo employeePersonalInfo = employeeHeader.EmployeePersonalInfo.FirstOrDefault();

            _employeeHeader.BranchId        = employeeHeader.BranchId;
            _employeeHeader.ManagerId       = employeeHeader.ManagerId;
            _employeeHeader.FirstName       = !string.IsNullOrWhiteSpace(employeeHeader.FirstName) ? employeeHeader.FirstName.ToUpper() : string.Empty;
            _employeeHeader.MiddleName      = !string.IsNullOrWhiteSpace(employeeHeader.MiddleName) ? employeeHeader.MiddleName.ToUpper() : string.Empty;
            _employeeHeader.LastName        = !string.IsNullOrWhiteSpace(employeeHeader.LastName) ? employeeHeader.LastName.ToUpper() : string.Empty;
            _employeeHeader.Nationality     = !string.IsNullOrWhiteSpace(employeeHeader.Nationality) ? employeeHeader.Nationality : string.Empty;
            _employeeHeader.IDNumber        = !string.IsNullOrWhiteSpace(employeeHeader.IDNumber) ? employeeHeader.IDNumber : string.Empty;
            _employeeHeader.IDType          = employeeHeader.IDType;
            _employeeHeader.UserEmailId     = employeeHeader.UserEmailId;
            _employeeHeader.Password        = employeeHeader.Password;
            _employeeHeader.IsActive        = employeeHeader.IsActive;
            _employeeHeader.ConfirmPassword = employeeHeader.ConfirmPassword;
            _employeeHeader.EmployeePersonalInfo.Add(PrepareEmployeePersonalInfo(employeePersonalInfo, _employeeHeader));
            _employeeHeader.Address.Add(PrepareEmployeeAddress(employeeHeader.Address.FirstOrDefault(), _employeeHeader));
            _employeeHeader.EmployeeWorkDetail.Add(PrepareEmployeeWorkDetail(employeeHeader.EmployeeWorkDetail.FirstOrDefault(), _employeeHeader));
            employeeHeader.User  = employeeHeader.User == null ? new User() : employeeHeader.User;
            _employeeHeader.User = PrepareUserDetails(employeeHeader.User, _employeeHeader);

            List <EmployeeDocument> employeeDocument = employeeHeader.EmployeeDocument != null ? employeeHeader.EmployeeDocument : new List <EmployeeDocument>();

            PrepareEmployeeDocuments(hfc, _employeeHeader, employeeDocument, employeeDocumentViewModel);
            return(_employeeHeader);
        }