Ejemplo n.º 1
0
        private ResultDto InsertUpdateEmployee(EmployeeDto employee)
        {
            ResultDto resultDto  = new ResultDto();
            string    objectName = "Employee";

            try
            {
                ObjectParameter paramEmployeeId   = new ObjectParameter("EmployeeID", employee.EmployeeID);
                ObjectParameter paramEmployeeCode = new ObjectParameter("EmployeeCode", string.Empty);
                int             effectedCount     = _dbContext.uspEmployeeInsertUpdate(paramEmployeeId, paramEmployeeCode, employee.EmployeeRefCode, employee.SurName, employee.TESurName,
                                                                                       employee.EmployeeName, employee.TEEmployeeName, employee.Photo, employee.BranchID, employee.ClusterID, employee.Gender, employee.DOJ,
                                                                                       employee.EducationQualification, employee.MobileNumber, employee.Email, employee.DOB, employee.Designation, employee.FromDate, employee.ToDate, employee.Disability,
                                                                                       employee.BloodGroup, employee.MaritalStatus, employee.SocialCategory, employee.PresentAddress, employee.PermanentAddress,
                                                                                       employee.EmergencyContactNumber, employee.EmergencyContactName, employee.UserID, employee.Religion, employee.DateOfRetirement);

                resultDto.ObjectId = (int)paramEmployeeId.Value;


                resultDto.ObjectCode = (string)paramEmployeeCode.Value;

                if (resultDto.ObjectId > 0)
                {
                    resultDto.Message = string.Format("{0} details saved successfully with code : {1}", objectName, resultDto.ObjectCode);
                }
                else if (resultDto.ObjectId == -1)
                {
                    resultDto.Message = string.Format("Error occured while generating {0} code", objectName);
                }
                else
                {
                    resultDto.Message = string.Format("Error occured while saving {0} details", objectName);
                }
            }
            catch (Exception)
            {
                resultDto.Message = string.Format("Service layer error occured while saving the {0} details", objectName);

                resultDto.ObjectId = -98;
            }
            return(resultDto);
        }