public ActionResult UpdateWorkHistory(WorkHistoryBO workHistory) { if (Session["EmpId"] == null || Session["EmpId"].Equals(0)) { return(RedirectToAction("Details", "Employee", new { E = 1 })); } workHistory.EmpId = Convert.ToInt32(Session["EmpId"]); var response = consumer.UpdateWorkHistory(workHistory); var responseWorkHistory = JsonConvert.DeserializeObject <object>(response.Content); if ((int)response.StatusCode == 200) { return(Json("Details Updated Successfully")); } else if ((int)response.StatusCode == 400) { throw new HttpException(400, "Details Not Udpated"); } else if ((int)response.StatusCode == 401) { throw new HttpException(401, "Not Authorized to udpate details"); } else { throw new HttpException(400, "Something wentwromg with the service"); } }
public async Task <HttpResponseMessage> getWorkHistory(int WHID, int EmpId) { try { if (WHID.Equals(0) || WHID.Equals(null)) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "No details found for given id : " + WHID)); } else if ((EmpId.Equals(0) || EmpId.Equals(null))) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "No details found for given id : " + WHID)); } else { WH = await db.getWorkHistory(WHID, EmpId); if (WH != null) { return(Request.CreateResponse(HttpStatusCode.OK, WH)); } else { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "No details found for given id : " + WHID)); } } } catch (Exception es) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, es.Message)); } }
public async Task <HttpResponseMessage> updateWorkHistory(WorkHistoryBO workHistory) { try { if (workHistory.WHID.Equals(0) || workHistory.WHID.Equals(null)) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "No details found for given id : " + workHistory.WHID)); } else { int result = await db.UpdateWorkHistory(workHistory); switch (result) { case 0: return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "details Not updated")); case 1: return(Request.CreateResponse(HttpStatusCode.OK, "details updated successfully")); case 2: return(Request.CreateErrorResponse(HttpStatusCode.Unauthorized, "Not Authorized to udpate these details")); default: return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "details Not updated")); } } } catch (Exception es) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, es.Message)); } }
public IRestResponse UpdateWorkHistory(WorkHistoryBO work) { var client = new RestClient(Url + ApexConfig.UdpateWorkHistory); var request = new RestRequest(Method.PUT); string jsonRequest = JsonConvert.SerializeObject(work); request.AddParameter( "application/json; charset=utf-8", jsonRequest, ParameterType.RequestBody); request.AddBody(jsonRequest); var response = client.Execute(request); return(response); }
public async Task <List <WorkHistoryBO> > GetWorkHistory(int EmpId) { try { con = await DBConnection.ApexConnection(); cmd = new DBConnection().BuildProcedureCommand("P_GetWorkRoles", con); cmd.Parameters.AddWithValue("@EmpId", EmpId); using (var reader = await cmd.ExecuteReaderAsync()) { List <WorkHistoryBO> LWorkHist = new List <WorkHistoryBO>(); WorkHistoryBO workHistory;//ssss = new WorkHistoryBO(); while (reader.Read()) { workHistory = new WorkHistoryBO(); workHistory.compId = Convert.ToInt32(reader["CompId"]); workHistory.compName = reader["CompanyName"].ToString(); workHistory.workLocation.street = reader["WLStreet"].ToString(); workHistory.workLocation.city = reader["WLcity"].ToString(); workHistory.workLocation.state = reader["WLstate"].ToString(); workHistory.workLocation.country = reader["WLCountry"].ToString(); workHistory.workLocation.Zipcode = reader["WLzipcode"].ToString(); workHistory.manager.MgrFullName = reader["ManagerName"].ToString(); workHistory.manager.MgrEmail = reader["ManagerEmail"].ToString(); workHistory.manager.MgrCountryCode = reader["ManagerCountryCode"].ToString(); workHistory.manager.MgrMobileNumb = reader["managerMobNumb"].ToString(); workHistory.manager.MgrisVerified = Convert.ToInt32(reader["ManagerVerified"]); workHistory.Responsibility = reader["RolesAndResp"].ToString(); workHistory.EmploymentId = reader["EmploymentID"].ToString(); workHistory.WorkRoles.FromDate = Convert.ToDateTime(reader["FromDate"]); workHistory.WorkRoles.isCurrentCompany = Convert.ToInt32(reader["isCurrent"]); workHistory.WorkRoles.ToDate = Convert.ToInt32(reader["isCurrent"]).Equals(1) ? null : reader["ToDate"].ToString(); workHistory.WorkRoles.Designation = reader["Designation"].ToString(); workHistory.WorkRoles.isCompVerified = Convert.ToInt32(reader["CompanyVerified"]); workHistory.WorkRoles.EmpType = Convert.ToInt32(reader["EmpType"]); workHistory.WHID = Convert.ToInt32(reader["WHID"]); workHistory.EmpId = Convert.ToInt32(reader["EmpId"]); LWorkHist.Add(workHistory); } con.Close(); return(LWorkHist); } } catch (Exception es) { throw es; } }
public async Task <int> UpdateWorkHistory(WorkHistoryBO workHistory) { try { con = await DBConnection.ApexConnection(); cmd = new DBConnection().BuildProcedureCommand("P_UPD_WORKHISTORY", con); cmd.Parameters.AddWithValue("@CompId", workHistory.compId); cmd.Parameters.AddWithValue("@CompName", workHistory.compName); cmd.Parameters.AddWithValue("@Street", workHistory.workLocation.street); cmd.Parameters.AddWithValue("@City", workHistory.workLocation.city); cmd.Parameters.AddWithValue("@State", workHistory.workLocation.state); cmd.Parameters.AddWithValue("@Country", workHistory.workLocation.country); cmd.Parameters.AddWithValue("@Zipcode", workHistory.workLocation.Zipcode); cmd.Parameters.AddWithValue("@ManagerFullName", workHistory.manager.MgrFullName); cmd.Parameters.AddWithValue("@managerEmail", workHistory.manager.MgrEmail); cmd.Parameters.AddWithValue("@managerCountryCode", workHistory.manager.MgrCountryCode); cmd.Parameters.AddWithValue("@managerMobilenumb", workHistory.manager.MgrMobileNumb); cmd.Parameters.AddWithValue("@RolesRespon", workHistory.Responsibility); cmd.Parameters.AddWithValue("@Empid", workHistory.EmpId); cmd.Parameters.AddWithValue("@fromDate", workHistory.WorkRoles.FromDate); cmd.Parameters.AddWithValue("@toDate", workHistory.WorkRoles.ToDate); cmd.Parameters.AddWithValue("@designation", workHistory.WorkRoles.Designation); cmd.Parameters.AddWithValue("@empType", workHistory.WorkRoles.EmpType); cmd.Parameters.AddWithValue("@iscurrentCompany", workHistory.WorkRoles.isCurrentCompany); cmd.Parameters.AddWithValue("@EmploymentID", workHistory.EmploymentId); cmd.Parameters.AddWithValue("@Whid", workHistory.WHID); using (var reader = await cmd.ExecuteReaderAsync()) { if (reader.Read()) { return(reader.GetInt32(0)); } else { return(0); } } } catch (Exception es) { throw es; } }
public async Task <HttpResponseMessage> InsertWorkHistory(WorkHistoryBO workHistory) { try { WH = await db.InsEmployeeDetails(workHistory); if (WH.compId != 0) { return(Request.CreateResponse(HttpStatusCode.Created, WH)); } else { return(Request.CreateErrorResponse(HttpStatusCode.Conflict, "something bad happened, please raise this to our notice")); } } catch (Exception es) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, es.Message)); } }
public ActionResult InsertWorkHistory(WorkHistoryBO workHistory) { workHistory.EmpId = (int)Session["EmpId"]; var response = consumer.InsertWorkHistory(workHistory); var responseWorkHistory = JsonConvert.DeserializeObject <WorkHistoryBO>(response.Content); if ((int)response.StatusCode == 201) { return(Json(responseWorkHistory)); } else if ((int)response.StatusCode == 401) { throw new HttpException(401, "Service failed to work as expected, bring it to our notice"); } else { if (ModelState.IsValid) { ModelState.AddModelError(string.Empty, "Something wrong, please raise the issue with support"); } throw new HttpException(500, "Internal server error!!"); } }
public async Task <WorkHistoryBO> InsEmployeeDetails(WorkHistoryBO workHistory) { try { con = await DBConnection.ApexConnection(); cmd = new DBConnection().BuildProcedureCommand("P_InsWorkHistory", con); cmd.Parameters.AddWithValue("@CompId", workHistory.compId); cmd.Parameters.AddWithValue("@CompName", workHistory.compName); cmd.Parameters.AddWithValue("@Street", workHistory.workLocation.street); cmd.Parameters.AddWithValue("@City", workHistory.workLocation.city); cmd.Parameters.AddWithValue("@State", workHistory.workLocation.state); cmd.Parameters.AddWithValue("@Country", workHistory.workLocation.country); cmd.Parameters.AddWithValue("@Zipcode", workHistory.workLocation.Zipcode); cmd.Parameters.AddWithValue("@ManagerFullName", workHistory.manager.MgrFullName); cmd.Parameters.AddWithValue("@managerEmail", workHistory.manager.MgrEmail); cmd.Parameters.AddWithValue("@managerCountryCode", workHistory.manager.MgrCountryCode); cmd.Parameters.AddWithValue("@managerMobilenumb", workHistory.manager.MgrMobileNumb); cmd.Parameters.AddWithValue("@RolesRespon", workHistory.Responsibility); cmd.Parameters.AddWithValue("@Empid", workHistory.EmpId); cmd.Parameters.AddWithValue("@fromDate", workHistory.WorkRoles.FromDate); cmd.Parameters.AddWithValue("@toDate", workHistory.WorkRoles.ToDate); cmd.Parameters.AddWithValue("@designation", workHistory.WorkRoles.Designation); cmd.Parameters.AddWithValue("@empType", workHistory.WorkRoles.EmpType); cmd.Parameters.AddWithValue("@iscurrentCompany", workHistory.WorkRoles.isCurrentCompany); cmd.Parameters.AddWithValue("@EmploymentID", workHistory.EmploymentId); using (var reader = await cmd.ExecuteReaderAsync()) { if (reader.Read()) { workHistory.compId = Convert.ToInt32(reader["CompId"]); workHistory.compName = reader["CompanyName"].ToString(); workHistory.workLocation.street = reader["WLStreet"].ToString(); workHistory.workLocation.city = reader["WLcity"].ToString(); workHistory.workLocation.state = reader["WLstate"].ToString(); workHistory.workLocation.country = reader["WLCountry"].ToString(); workHistory.workLocation.Zipcode = reader["WLzipcode"].ToString(); workHistory.manager.MgrFullName = reader["ManagerName"].ToString(); workHistory.manager.MgrEmail = reader["ManagerEmail"].ToString(); workHistory.manager.MgrCountryCode = reader["ManagerCountryCode"].ToString(); workHistory.manager.MgrMobileNumb = reader["managerMobNumb"].ToString(); workHistory.manager.MgrisVerified = Convert.ToInt32(reader["ManagerVerified"]); workHistory.Responsibility = reader["RolesAndResp"].ToString(); workHistory.EmploymentId = reader["EmploymentID"].ToString(); workHistory.WorkRoles.FromDate = Convert.ToDateTime(reader["FromDate"]); workHistory.WorkRoles.isCurrentCompany = Convert.ToInt32(reader["isCurrent"]); workHistory.WorkRoles.ToDate = Convert.ToInt32(reader["isCurrent"]).Equals(1) ? null : reader["ToDate"].ToString(); workHistory.WorkRoles.Designation = reader["Designation"].ToString(); workHistory.WorkRoles.isCompVerified = Convert.ToInt32(reader["CompanyVerified"]); workHistory.WorkRoles.EmpType = Convert.ToInt32(reader["EmpType"]); workHistory.WHID = Convert.ToInt32(reader["WHID"]); return(workHistory); } else { WorkHistoryBO WH = new WorkHistoryBO(); return(WH); } } } catch (Exception es) { throw es; } }