public object AddTravellerCheckInDetails(TravellerCheckIn _traveller) { bool IsSuccess = true; IDbTransaction transaction = null; object objResult = null; DataTable dtResult = null; IDbConnection con = null; try { transaction = DALHelper.GetTransaction(); con = DALHelper.GetConnection(); Int64 resultID = _travellerDL.AddTravellerCheckInDetails(_traveller, transaction); if (resultID > 0) { if (_traveller.Action == "1") // Check In { dtResult = _travellerDL.GetTravellerChekInInfo(_traveller, transaction, "4"); objResult = dtResult; } else if (_traveller.Action == "2") // Check Out { dtResult = _travellerDL.GetTravellerChekInInfo(_traveller, transaction, "5"); objResult = dtResult; } } else if (resultID == -1) { objResult = "Traveller already Checked In"; } else if (resultID == -3) { objResult = "Traveller is not Checked In"; } else if (resultID == -4) { objResult = "QRCode not found"; } } catch (Exception ex) { ErrorLogDL.InsertErrorLog(ex.Message, "AddTravellerCheckInDetails"); IsSuccess = false; throw; } finally { DALHelper.CloseDB(transaction, IsSuccess); } return(objResult); }
public Int16 AddTravellerCheckInDetails(TravellerCheckIn _traveller, IDbTransaction transaction) { try { IDbDataParameter[] paramData; Int16 Result = 0; paramData = DALHelperParameterCache.GetSpParameterSet(transaction, "InsertTravellerCheckInCheckOutDetails"); foreach (IDbDataParameter Item in paramData) { switch (Item.ParameterName) { case "HostelId": Item.Value = _traveller.hostelId; break; case "QRCode": Item.Value = _traveller.travellerQRCode; break; case "Status": Item.Value = _traveller.Action; break; case "checkInDate": Item.Value = _traveller.checkInDate; break; case "checkOutDate": Item.Value = _traveller.checkOutDate; break; case "TrackingId": Item.Value = _traveller.trackingId; break; case "IsPointsSpent": Item.Value = _traveller.isPontsSpent; break; case "NoOfPointsSpent": Item.Value = _traveller.NoOfPointsSpent; break; } } Result = Convert.ToInt16(DALHelper.ExecuteNonQuery(transaction, CommandType.StoredProcedure, "InsertTravellerCheckInCheckOutDetails", paramData)); return(Result); } catch (Exception ex) { ErrorLogDL.InsertErrorLog(ex.Message, "AddTravellerCheckInDetails"); throw ex; } }
public DataTable GetTravellerChekInInfo(TravellerCheckIn _traveller, IDbTransaction transaction, string mode) { DataSet dsResult = new DataSet(); try { IDbDataParameter[] paramData; paramData = DALHelperParameterCache.GetSpParameterSet(transaction, "GetTravellerCheckinDetails"); foreach (IDbDataParameter Item in paramData) { switch (Item.ParameterName) { case "TravellerId": Item.Value = 0; break; case "TravellerQrCode": Item.Value = _traveller.travellerQRCode; break; case "HostelId": Item.Value = _traveller.hostelId; break; case "Mode": Item.Value = mode; break; } } DALHelper.FillDataset(transaction, CommandType.StoredProcedure, "GetTravellerCheckinDetails", dsResult, new string[] { "Traveller" }, paramData); return(dsResult.Tables.Contains("Traveller") ? dsResult.Tables["Traveller"] : null); } catch (Exception ex) { ErrorLogDL.InsertErrorLog(ex.Message, "GetTravellerChekInInfo"); throw ex; } }
public async Task <IHttpActionResult> CheckInCheckOut() { TravellerCheckIn _traveller = new TravellerCheckIn(); // Check if the request contains multipart/form-data. if (!Request.Content.IsMimeMultipartContent()) { throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType); } var provider = await Request.Content.ReadAsMultipartAsync <InMemoryMultipartFormDataStreamProvider>(new InMemoryMultipartFormDataStreamProvider()); //access form data NameValueCollection formData = provider.FormData; try { _traveller.hostelId = Convert.ToInt32(formData["hostelId"]); _traveller.travellerQRCode = formData["travellerQRCode"]; _traveller.trackingId = string.IsNullOrEmpty(formData["trackingId"]) ? 0 : Convert.ToInt64(formData["trackingId"]); // _traveller.checkInDate = string.IsNullOrEmpty(formData["checkInDate"]) ? Convert.ToDateTime(formData["checkInDate"]) : System.DateTime.Now; // _traveller.checkOutDate = string.IsNullOrEmpty(formData["checkOutDate"]) ? Convert.ToDateTime(formData["checkOutDate"]) : System.DateTime.Now; _traveller.Action = formData["status"]; if (!string.IsNullOrEmpty(formData["checkInDate"])) { _traveller.checkInDate = Convert.ToDateTime(formData["checkInDate"].ToString()); } else { _traveller.checkInDate = System.DateTime.Now; } if (!string.IsNullOrEmpty(formData["checkOutDate"])) { _traveller.checkOutDate = Convert.ToDateTime(formData["checkOutDate"].ToString()); } else { _traveller.checkOutDate = System.DateTime.Now; } _traveller.isPontsSpent = Convert.ToBoolean(formData["isPointsSpent"]); _traveller.NoOfPointsSpent = (string.IsNullOrEmpty(formData["noOfPoints"].ToString())) ? 0 : Convert.ToInt16(formData["noOfPoints"]); } catch (Exception ex) { ErrorLogDL.InsertErrorLog(ex.Message, "Error Is Logged without conversion " + formData["checkInDate"].ToString()); ErrorLogDL.InsertErrorLog(ex.Message, "Error Is Logged with conversion" + Convert.ToDateTime(formData["checkInDate"].ToString())); ErrorLogDL.InsertErrorLog(ex.Message, formData["hostelId"]); ErrorLogDL.InsertErrorLog(ex.Message, formData["trackingId"]); ErrorLogDL.InsertErrorLog(ex.Message, formData["status"]); } return(Ok(travellerBL.AddTravellerCheckInDetails(_traveller))); }