public ORFIDCheckInOut exit(RFIDCheckOut objCheckOut) { DALExceptionManagment objExceptionlog = new DALExceptionManagment(); ORFIDCheckInOut obj_CheckInOut = new ORFIDCheckInOut(); string resultMsg = string.Empty; try { using (SqlConnection sqlconn_obj = new SqlConnection(SqlHelper.GetDBConnectionString())) { using (SqlCommand sqlcmd_obj = new SqlCommand("CTAPP_PROC_INSERTRFIDCHECKINOUT", sqlconn_obj)) { sqlcmd_obj.CommandType = CommandType.StoredProcedure; sqlcmd_obj.Parameters.AddWithValue("@RFIDCheckInOutID", 1); sqlcmd_obj.Parameters.AddWithValue("@LocationID", objCheckOut.locationId); sqlcmd_obj.Parameters.AddWithValue("@LotID", objCheckOut.lotId); sqlcmd_obj.Parameters.AddWithValue("@BeaconID", objCheckOut.beaconId); sqlcmd_obj.Parameters.AddWithValue("@AvgTimeDuration", DBNull.Value); DateTimeOffset dateTimeOffset = DateTimeOffset.FromUnixTimeSeconds(objCheckOut.checkOutTime).ToLocalTime(); DateTime checkOutDateTime = dateTimeOffset.DateTime; sqlcmd_obj.Parameters.AddWithValue("@CheckInTime", DBNull.Value); sqlcmd_obj.Parameters.AddWithValue("@CheckOutTime", checkOutDateTime); sqlconn_obj.Open(); SqlDataAdapter sqldap = new SqlDataAdapter(sqlcmd_obj); DataTable resultdt = new DataTable(); sqldap.Fill(resultdt); if (resultdt.Rows.Count > 0) { obj_CheckInOut.RFIDCheckInOutID = Convert.ToInt32(resultdt.Rows[0]["RFIDCheckInOutID"]); } else { obj_CheckInOut.RFIDCheckInOutID = 0; } } } } catch (Exception ex) { objExceptionlog.InsertException(ex.Message, "DALRFID", "Proc: " + "CTAPP_PROC_INSERTRFIDCHECKINOUT", "exit"); //throw; obj_CheckInOut.RFIDCheckInOutID = 0; } return(obj_CheckInOut); }
public HttpResponseMessage exit(RFIDCheckOut obj) { ObjAPIResponse = new RFIDAPIResponse(); var resp = new HttpResponseMessage(HttpStatusCode.OK); try { DALRFID dal_RFID = new DALRFID(); ORFIDCheckInOut resultobj = dal_RFID.exit(obj); //if (resultobj.RFIDCheckInOutID != 0) //{ // ObjAPIResponse.Result = true; // ObjAPIResponse.Message = "Success"; //} //else //{ // ObjAPIResponse.Result = false; // ObjAPIResponse.Message = "Fail"; // resp = new HttpResponseMessage(HttpStatusCode.InternalServerError); //} ObjAPIResponse.Result = true; ObjAPIResponse.Message = "Success"; resp.Content = new StringContent(JsonConvert.SerializeObject(ObjAPIResponse)); resp.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); } catch (Exception ex) { ObjAPIResponse.Result = true; ObjAPIResponse.Message = "Success"; /* * ObjAPIResponse.Result = false; * ObjAPIResponse.Message = "Please contact administrator : " + ex.Message; * resp = new HttpResponseMessage(HttpStatusCode.InternalServerError); */ resp.Content = new StringContent(JsonConvert.SerializeObject(ObjAPIResponse)); resp.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); } return(resp); }