Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public JsonResult SaveEmployeeDocuments()
        {
            var employeeId            = Convert.ToInt16(System.Web.HttpContext.Current.Request["employeeId"]);
            HttpFileCollection hfc    = System.Web.HttpContext.Current.Request.Files;
            JsonResult         result = null;

            try
            {
                EmployeeDocument employeeDocument = null;
                HttpPostedFile   file             = hfc[0];
                employeeDocument = EmployeeProfileService.GetEmployeeDocuments <EmployeeDocument>(ed => ed.EmployeeHeaderId == employeeId).FirstOrDefault();

                //EmployeeHeader employeeHeader = EmployeeProfileService.GetEmployeeDocuments(Convert.ToInt16(employeeId));
                if (employeeDocument != null)
                {
                    employeeDocument.ModifiedBy = USER_OBJECT.UserID;
                    employeeDocument.ModifiedOn = DateTimeConverter.SingaporeDateTimeConversion(DateTime.Now);
                }
                else
                {
                    employeeDocument           = new EmployeeDocument();
                    employeeDocument.CreatedBy = USER_OBJECT.UserID;
                    employeeDocument.CreatedOn = DateTimeConverter.SingaporeDateTimeConversion(DateTime.Now);
                }
                EmployeeHeader EmployeeHeader = EmployeeProfileService.GetEmployeeProfileList <EmployeeHeader>(s => s.Id == employeeId).FirstOrDefault();
                employeeDocument.FileName         = System.IO.Path.GetFileName(file.FileName);
                employeeDocument.BranchId         = USER_OBJECT.BranchId;
                employeeDocument.EmployeeHeaderId = Convert.ToInt32(employeeId);
                employeeDocument.DocumentType     = LookUpCodeService.GetLookUp <LookUp>(l => l.LookUpCode == "ProfilePic").Select(s => s.LookUpID).FirstOrDefault();
                SaveFile(file);
                EmployeeHeader.EmployeeDocument.Add(employeeDocument);
                if (employeeDocument != null)
                {
                    EmployeeProfileService.SaveEmployeeDocuments(employeeDocument);
                }
            }
            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);
        }