Exemplo n.º 1
0
 public JsonResult SetEmpGallery(int EmpId, string jsonData)
 {
     NuPortalEmpService.NuPortalEmployeeService empService = new NuPortalEmpService.NuPortalEmployeeService();
     empService.Url = Constants.EmpService;
     try
     {
         bool IsSuccess = empService.SetEmpGallery(EmpId, jsonData);
         if (IsSuccess)
         {
             return(Json(Common_Library.Constants.JsonSuccess));
         }
     }
     catch (Exception ex)
     {
         GeneralFunctions genFun = new GeneralFunctions();
         genFun.LogError(ControllerContext.HttpContext, ex.Message, ex.TargetSite.Name,
                         Convert.ToString(ControllerContext.RouteData.Values["action"]),
                         Convert.ToString(ControllerContext.RouteData.Values["controller"]));
         genFun = null;
     }
     finally
     {
         empService = null;
     }
     return(Json(Common_Library.Constants.JsonError));
 }
        public ActionResult EmpInfoAdminView(HttpPostedFileBase file, NuPortal.Models.EmpInfoAdminView empDetails, int?hdnId)
        {
            string path = string.Empty;

            Common_Library.GeneralFunctions            general    = new Common_Library.GeneralFunctions();
            NuPortalEmpService.NuPortalEmployeeService empService = new NuPortalEmpService.NuPortalEmployeeService();
            NuPortalRecruitmentService.Recruitment     recService = new NuPortalRecruitmentService.Recruitment();
            empService.Url = Constants.EmpService;
            recService.Url = Constants.RecruitmentService;
            Dictionary <string, int> dictEmpData = new Dictionary <string, int>();

            try
            {
                if (hdnId == null)
                {
                    //DateTime JDate= Convert.ToDateTime(DateTime.ParseExact(empDetails.joiningDate, "yyyy/MM/dd", null).ToString("dd/MM/yyyy"));
                    DateTime      JDate         = Convert.ToDateTime(DateTime.ParseExact(empDetails.joiningDate, "MM/dd/yyyy", null).ToString("yyyy/MM/dd"));
                    bool          IsSuccess     = false;
                    string[]      imageUrlArray = new string[] { };
                    string[]      quoteArray    = new string[] { };
                    StringBuilder sb            = new StringBuilder();
                    if (empDetails.applicantId == 0)
                    {
                        string JsonData = empService.CreateEmployee(empDetails.firstName, empDetails.lastName == null ? "" : empDetails.lastName, empDetails.titleId == null ? "" : empDetails.titleId,
                                                                    empDetails.employeeCode,
                                                                    Convert.ToInt32(empDetails.designationId), empDetails.reportingTo, empDetails.profilePicUrl == null ? "" : empDetails.profilePicUrl,
                                                                    empDetails.passPicUrl == null ? "" : empDetails.passPicUrl, empDetails.bgPicUrl == null ? "" : empDetails.bgPicUrl,
                                                                    JDate, general.SetDateVal(empDetails.confirmationDate), empDetails.officeEmailId,
                                                                    Convert.ToInt32(empDetails.officeLocationId), empDetails.workLocation == null ? "" : empDetails.workLocation,
                                                                    empDetails.employementId == null ? 0 : Convert.ToInt32(empDetails.employementId), general.SetDateVal(empDetails.relievingDate), 1, empDetails.employmentStatusId != null ? Convert.ToInt32(empDetails.employmentStatusId) : 0,
                                                                    DateTime.Now, DateTime.Now, Convert.ToInt32(Session["EmpID"]), Convert.ToInt32(Session["EmpID"]), empDetails.weekOffDays,
                                                                    empDetails.workStartTime == null ? "" : empDetails.workStartTime, empDetails.workEndTime == null ? "" : empDetails.workEndTime, empDetails.quotes == null ? "" : empDetails.quotes);
                        dictEmpData = JsonConvert.DeserializeObject <Dictionary <string, int> >(JsonData);
                        if (!string.IsNullOrEmpty(empDetails.imageUrl) && dictEmpData["EmpId"] > 0)
                        {
                            imageUrlArray = empDetails.imageUrl.Split('|');
                            quoteArray    = empDetails.quoteText.Split('|');
                            sb.Append("[");
                            for (int i = 0; i < imageUrlArray.Length - 1; i++)
                            {
                                sb.Append("{\"FK_EmpId\":" + dictEmpData["EmpId"] + ",\"QuotesPictureUrl\":\"" + imageUrlArray[i] + "\",\"QuotesText\":\"" + quoteArray[i] + "\"},");
                            }
                            sb.Length--;
                            sb.Append("]");
                            IsSuccess = empService.SetEmpGallery(dictEmpData["EmpId"], Convert.ToString(sb).TrimEnd('}').TrimStart('{'));
                        }
                    }
                    else
                    {
                        var newId = recService.CreateJoinedEmployee(empDetails.applicantId, empDetails.firstName, empDetails.lastName == null ? "" : empDetails.lastName, empDetails.titleId == null ? "" : empDetails.titleId,
                                                                    empDetails.employeeCode, Convert.ToInt32(empDetails.designationId), empDetails.reportingTo, empDetails.profilePicUrl == null ? "" : empDetails.profilePicUrl,
                                                                    empDetails.passPicUrl == null ? "" : empDetails.passPicUrl, empDetails.bgPicUrl == null ? "" : empDetails.bgPicUrl, JDate, general.SetDateVal(empDetails.confirmationDate), empDetails.officeEmailId == null ? "" : empDetails.officeEmailId,
                                                                    Convert.ToInt32(empDetails.officeLocationId), empDetails.workLocation == null ? "" : empDetails.workLocation, empDetails.employementId == null ? 0 : Convert.ToInt32(empDetails.employementId), general.SetDateVal(empDetails.relievingDate), 1, empDetails.employmentStatusId != null ? Convert.ToInt32(empDetails.employmentStatusId) : 0,
                                                                    DateTime.Now, DateTime.Now, Convert.ToInt32(Session["EmpID"]), Convert.ToInt32(Session["EmpID"]), empDetails.weekOffDays,
                                                                    empDetails.workStartTime == null ? "" : empDetails.workStartTime, empDetails.workEndTime == null ? "" : empDetails.workEndTime, empDetails.quotes == null ? "" : empDetails.quotes);
                        if (!string.IsNullOrEmpty(newId))
                        {
                            IsSuccess = true;
                        }
                    }
                    if (empDetails.applicantId == 0 && dictEmpData["EmpId"] > 0 && dictEmpData["MailStatus"] == 1)
                    {
                        ModelState.Clear();
                        ViewBag.Message = "Employee Created Successfully";
                    }
                    else if (empDetails.applicantId == 0 && dictEmpData["EmpId"] > 0 && dictEmpData["MailStatus"] == 0)
                    {
                        ViewBag.Message = "Error in sending mail";
                    }
                    else if (empDetails.applicantId > 0 && IsSuccess)
                    {
                        ModelState.Clear();
                        ViewBag.Message = "Employee Created Successfully";
                    }
                    else
                    {
                        ViewBag.Message = "Error in saving data";
                    }
                }
            }
            catch (Exception ex)
            {
                GeneralFunctions genFun = new GeneralFunctions();
                genFun.LogError(ControllerContext.HttpContext, ex.Message, ex.TargetSite.Name,
                                Convert.ToString(ControllerContext.RouteData.Values["action"]),
                                Convert.ToString(ControllerContext.RouteData.Values["controller"]));
                genFun = null;
            }
            finally
            {
                empDetails  = null;
                empService  = null;
                general     = null;
                dictEmpData = null;
            }
            return(EmpInfoAdminView(hdnId));
        }