public HttpResponseMessage AddNewTaxDeclaration(Incometax incometax) { HttpResponseMessage response = null; try { if (incometax != null) { incometax.is_active = 1; incometax.to_date = null; IncometaxRepo.AddNewTaxDeclaration(incometax); response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_001", "Tax declaration added Successfully", "Tax declaration added Successfully")); } else { response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_102", "Invalid Input", "Please check input Json")); } } catch (DbEntityValidationException DBexception) { Debug.WriteLine(DBexception.Message); Debug.WriteLine(DBexception.GetBaseException()); response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_190", "Mandatory fields missing", DBexception.Message)); } catch (Exception exception) { Debug.WriteLine(exception.Message); Debug.WriteLine(exception.GetBaseException()); response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_101", "Application Error", exception.Message)); } return(response); }
public HttpResponseMessage AddTimeSheetRecord(List <Timesheet> sheetrecord) { HttpResponseMessage response = null; try { if (sheetrecord != null) { TimeSheetRepo.AddTimeSheetRecord(sheetrecord); response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_001", "TimeSheet added Succesfully", "TimeSheet added Succesfully")); } else { response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_102", "Invalid Input", "Please check input Json")); } } catch (DbEntityValidationException DBexception) { Debug.WriteLine(DBexception.Message); Debug.WriteLine(DBexception.GetBaseException()); response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_190", "Mandatory fields missing", DBexception.Message)); } catch (Exception exception) { Debug.WriteLine(exception.Message); Debug.WriteLine(exception.GetBaseException()); response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_101", "Application Error", exception.Message)); } return(response); }
public HttpResponseMessage CreateHoliday(Holiday_List holiday_list) { HttpResponseMessage response = null; try { if (holiday_list != null) { LeaveRepo.CreateHoliday(holiday_list); response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_001", "Holiday successfully created", "Holiday successfully created")); } else { response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_102", "Invalid Input", "Please check input Json")); } } catch (DbEntityValidationException DBexception) { Debug.WriteLine(DBexception.Message); Debug.WriteLine(DBexception.GetBaseException()); response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_190", "Mandatory fields missing", DBexception.Message)); } catch (Exception exception) { Debug.WriteLine(exception.Message); Debug.WriteLine(exception.GetBaseException()); response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_101", "Application Error", exception.Message)); } return(response); }
public HttpResponseMessage AssignProjectTask(List <Task> task) { HttpResponseMessage response = null; try { if (task != null) { foreach (Task items in task) { Project proj_details = ProjectRepo.GetProjectById(items.project_id); if (proj_details != null) { TaskRepo.AssignProjectTask(items); response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_001", "Tasks assigned successfully", "Tasks assigned successfully")); } else { response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_204", "Project ID doesnot Exists", "Project ID doesnot Exists")); } } } else { response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_102", "Invalid Input", "Please check input Json")); } } catch (DbEntityValidationException DBexception) { Debug.WriteLine(DBexception.Message); Debug.WriteLine(DBexception.GetBaseException()); response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_190", "Mandatory fields missing", DBexception.Message)); } catch (Exception exception) { Debug.WriteLine(exception.Message); Debug.WriteLine(exception.GetBaseException()); response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_101", "Application Error", exception.Message)); } return(response); }
public HttpResponseMessage CreateNewClient(Client client) { HttpResponseMessage Response = null; try { if (client != null) { Client existingInstance = ClientRepo.GetExistingClientInstance(client.client_name, client.type_id); if (existingInstance == null) { client.is_active = 1; ClientRepo.CreateNewClient(client); Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_001", "Client added successfully", "Client added successfully")); } else { Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_201", "Client already exists", "Client already exists")); } } else { Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_102", "Failure", "Please check the Json input")); } } catch (DbEntityValidationException DBexception) { Debug.WriteLine(DBexception.Message); Debug.WriteLine(DBexception.GetBaseException()); Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_190", "Mandatory fields missing", DBexception.Message)); } catch (Exception exception) { Debug.WriteLine(exception.Message); Debug.WriteLine(exception.GetBaseException()); Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_101", "Application Error", exception.Message)); } return(Response); }
public HttpResponseMessage CreateNewProject(Project project) { HttpResponseMessage Response = null; try { if (project != null) { Project existingInstance = ProjectRepo.GetExistingProject(project.project_name, project.client_id); if (existingInstance == null) { ProjectRepo.CreateNewProject(project); Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_001", "Project added successfully", "Project added successfully")); } else { Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_203", "Project ID already exists", "Project ID already exists")); } } else { Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_102", "Please check the Json input", "Please check the Json input")); } } catch (DbEntityValidationException DBexception) { Debug.WriteLine(DBexception.Message); Debug.WriteLine(DBexception.GetBaseException()); Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_190", "Some Mandatory fields are missing", DBexception.Message)); } catch (Exception exception) { Debug.WriteLine(exception.Message); Debug.WriteLine(exception.GetBaseException()); Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_101", "Application Error", exception.Message)); } return(Response); }
public HttpResponseMessage CreateNewEmployee(EmployeeModel employee_details) { HttpResponseMessage Response = null; try { if (employee_details != null && employee_details.role_id != 0 /*&& employee_details.ctc != 0*/ && employee_details.id != 0 && employee_details.reporting_to != 0 && employee_details.designation_id != 0) { Employee existingInstance = EmployeeRepo.GetEmployeeById(employee_details.id); List <Employee> employeeByMailid = EmployeeRepo.GetEmployeeByMailId(employee_details.email); if (existingInstance != null) { Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_402", "Employee ID already exists", "Employee ID already exists")); return(Response); } if (employeeByMailid.Count != 0) { Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_402", "Mail ID already exists", "Mail ID already exists")); return(Response); } Employee employee = new Employee(); employee.id = employee_details.id; employee.first_name = employee_details.first_name; employee.last_name = employee_details.last_name; employee.email = employee_details.email; employee.date_of_birth = employee_details.date_of_birth; employee.date_of_joining = employee_details.date_of_joining; employee.contact_no = employee_details.contact_no; employee.reporting_to = employee_details.reporting_to; employee.year_of_experience = Decimal.Parse(employee_details.Year_of_experience); employee.gender = employee_details.gender; employee.pan_no = employee_details.pan_no; employee.bank_account_no = employee_details.bank_account_no; employee.emergency_contact_no = employee_details.emergency_contact_no; employee.emergency_contact_person = employee_details.emergency_contact_person; employee.PF_no = employee_details.PF_no; employee.medical_insurance_no = employee_details.medical_insurance_no; employee.blood_group = employee_details.blood_group; employee.designation = employee_details.designation_id; employee.created_on = DateTime.Now; bool isEmail = Regex.IsMatch(employee.email, @"^([0-9a-zA-Z]" + //Start with a digit or alphabetical @"([\+\-_\.][0-9a-zA-Z]+)*" + // No continuous or ending +-_. chars in email @")+" + @"@(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]*\.)+[a-zA-Z0-9]{2,17})$" , RegexOptions.IgnoreCase); if (isEmail != true) { Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_402", "Enter valid MailId", "Enter valid MailId")); } else if ((employee.date_of_birth.Year > (DateTime.Now.Year - 21))) { Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_402", "Employee age is below 21 years", "Employee age is below 21 years")); } else { User user = new User(); user.user_name = employee.email; string Temp_password = PasswordGenerator.GeneratePassword(); //Debug.WriteLine(Temp_password); user.password = EncryptPassword.CalculateHash(Temp_password); //Debug.WriteLine(user.password); user.is_active = 1; EmployeeRepo.CreateNewUser(user); employee.user_id = user.id; EmployeeRepo.CreateNewEmployee(employee); User_role user_role = new User_role(); user_role.user_id = user.id; user_role.role_id = employee_details.role_id; EmployeeRepo.AssignEmployeeRole(user_role); if (employee.gender.ToLower() == "male") { EmployeeRepo.InsertLeaveBalance(employee, Constants.MALE_LEAVE_TYPES); } else { EmployeeRepo.InsertLeaveBalance(employee, Constants.FEMALE_LEAVE_TYPES); } Salary_Structure salary = new Salary_Structure(); salary = SalaryCalculation.CalculateSalaryStructure(employee_details.ctc); salary.emp_id = employee_details.id; salary.is_active = 1; salary.from_date = DateTime.Now; salary.to_date = null; SalaryRepo.CreateSalaryStructure(salary); Payslip payslip = new Payslip(); payslip = SalaryCalculation.FirstMonthSalary(employee_details.date_of_joining, salary); if (payslip != null) { PayslipRepo.AddPayslip(payslip); } else { Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_401", "Error in salary structure generation or payslip generation", "Error in salary structure generation or payslip generation")); return(Response); } string username = employee.first_name + " " + employee.last_name; MailHandler.PasswordMailingFunction(username, employee.email, Temp_password); Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_001", "Employee added Successfully", "Employee added Successfully")); } } else { Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_190", "Invalid Input - check the fileds", "Invalid Input - check the fileds")); } } catch (DbEntityValidationException DBexception) { Debug.WriteLine(DBexception.Message); Debug.WriteLine(DBexception.GetBaseException()); Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_190", "Mandatory fields missing or Type mismatch", DBexception.Message)); } catch (Exception exception) { Debug.WriteLine(exception.Message); Debug.WriteLine(exception.GetBaseException()); Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_101", "Application Error", exception.Message)); } return(Response); }