public string ChangeUserAuthentication(User _user, string newPassword) { bool IsSuccess = true; string message = ""; IDbTransaction transaction = null; try { transaction = DALHelper.GetTransaction(); Int64 resultID = _loginDL.ChangePassword(_user, transaction, newPassword); if (resultID > 0) { message = "Password changed sucessfully"; } else if (resultID == -1) { message = "OldPasword is incorrect."; } } catch (Exception ex) { IsSuccess = false; ErrorLogDL.InsertErrorLog(ex.Message, "RegisterTravellerUser"); throw; } finally { DALHelper.CloseDB(transaction, IsSuccess); } return(message); }
public object GetTravellerProfile(Int64 travellerID) { object objResult = null; DataTable dtResult = null; IDbConnection con = null; try { con = DALHelper.GetConnection(); dtResult = _travellerDL.GetTravellerProfile(travellerID, con); if (dtResult.Rows.Count > 0) { objResult = dtResult; } else { objResult = null; } } catch (Exception ex) { ErrorLogDL.InsertErrorLog(ex.Message, "GetTravellerProfile"); } return(objResult); }
public object GetTravellerCheckInHistory(Int64 travellerID, string mode) { object objResult = null; DataTable dtResult = null; IDbConnection con = null; try { con = DALHelper.GetConnection(); dtResult = _travellerDL.GetTravellerCheckInHistory(travellerID, con, mode); if (dtResult.Rows.Count > 0) { objResult = dtResult; } else { objResult = "No data found"; } } catch (Exception ex) { ErrorLogDL.InsertErrorLog(ex.Message, "GetTravellerCheckInHistory"); } return(objResult); }
public string ResetPassword(User _user) { bool IsSuccess = true; string message = ""; IDbTransaction transaction = null; try { transaction = DALHelper.GetTransaction(); Int64 resultID = _loginDL.ResetPassword(_user, transaction); if (resultID > 0) { message = "Password reset sucessfully"; } else { message = "unable to reset password please contact support provider"; } } catch (Exception ex) { IsSuccess = false; ErrorLogDL.InsertErrorLog(ex.Message, "ResetPassword"); throw; } finally { DALHelper.CloseDB(transaction, IsSuccess); } return(message); }
public object ValidateEmail(string email) { object objResult = null; Int64 Result = 0; IDbConnection con = null; try { con = DALHelper.GetConnection(); Result = _loginDL.ValidateEmail(email, con); if (Result > 0) { objResult = Result; } else { objResult = false; } } catch (Exception ex) { ErrorLogDL.InsertErrorLog(ex.Message, "ValidateEmail"); } return(objResult); }
public object GetAllTravellerCheckInDetails(Int64 hostelId, string mode) { object objResult = null; DataTable dtResult = null; IDbConnection con = null; try { con = DALHelper.GetConnection(); dtResult = _hostelDL.GetAllTravellerCheckInDetails(hostelId, con, mode); if (dtResult.Rows.Count > 0) { objResult = dtResult; } else { objResult = "No ChecK In found"; } } catch (Exception ex) { ErrorLogDL.InsertErrorLog(ex.Message, "GetAllTravellerCheckInDetails"); } return(objResult); }
public object GetGallery(int hostelId) { object objResult = null; DataTable dtResult = null; IDbConnection con = null; try { con = DALHelper.GetConnection(); dtResult = _hostelDL.GetGallery(hostelId, con); if (dtResult.Rows.Count > 0) { objResult = dtResult; } else { objResult = "No gallery found"; } } catch (Exception ex) { ErrorLogDL.InsertErrorLog(ex.Message, "GetGallery"); } return(objResult); }
public Boolean InsertHelpUs(Int64 userId, string title, string message) { bool IsSuccess = true; bool result = false; IDbTransaction transaction = null; try { transaction = DALHelper.GetTransaction(); Int64 resultID = _loginDL.InsertHelpUs(userId, title, message, transaction); if (resultID > 0) { result = true; } else { result = false; } } catch (Exception ex) { IsSuccess = false; ErrorLogDL.InsertErrorLog(ex.Message, "InsertHelpUs"); throw; } finally { DALHelper.CloseDB(transaction, IsSuccess); } return(result); }
public object GetHostelProfile(int hostelId) { object objResult = null; DataTable dtResult = null; Dictionary <string, object> dsResult = new Dictionary <string, object>(); IDbConnection con = null; try { con = DALHelper.GetConnection(); dtResult = _hostelDL.GetHostelProfile(hostelId, con); if (dtResult.Rows.Count > 0) { objResult = dtResult; dsResult.Add("Profile", dtResult); dtResult = _hostelDL.GetGallery(hostelId, con); dsResult.Add("Gallery", dtResult); } else { objResult = "No data found"; } } catch (Exception ex) { ErrorLogDL.InsertErrorLog(ex.Message, "GetHostelProfile"); } return(dsResult); }
public object GetHostels(string key) { object objResult = null; DataTable dtResult = null; IDbConnection con = null; try { con = DALHelper.GetConnection(); dtResult = _hostelDL.GetHostelsByKey(key, con); if (dtResult.Rows.Count > 0) { objResult = dtResult; } else { objResult = null; } } catch (Exception ex) { ErrorLogDL.InsertErrorLog(ex.Message, "GetHostels"); } return(objResult); }
public DataTable GetTravellerProfile(Int64 travellerID, IDbConnection con) { DataSet dsResult = new DataSet(); try { IDbDataParameter[] paramData; paramData = DALHelperParameterCache.GetSpParameterSet(con, "GetTravellerProfile"); foreach (IDbDataParameter Item in paramData) { switch (Item.ParameterName) { case "TravellerId": Item.Value = travellerID; break; } } DALHelper.FillDataset(con, CommandType.StoredProcedure, "GetTravellerProfile", dsResult, new string[] { "TravellerProfile" }, paramData); return(dsResult.Tables.Contains("TravellerProfile") ? dsResult.Tables["TravellerProfile"] : null); } catch (Exception ex) { ErrorLogDL.InsertErrorLog(ex.Message, "GetTravellerProfile"); throw ex; } }
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 Int16 RegisterTravellerUser(Traveller _traveller, IDbTransaction transaction) { try { IDbDataParameter[] paramData; Int16 Result = 0; paramData = DALHelperParameterCache.GetSpParameterSet(transaction, "InsertTravellerProfile"); foreach (IDbDataParameter Item in paramData) { switch (Item.ParameterName) { case "UserId": Item.Value = _traveller.UserId; break; case "Password": Item.Value = _traveller.password; break; case "EmailId": Item.Value = _traveller.emailId; break; case "Address": Item.Value = ""; break; case "UserType": Item.Value = "Traveller"; break; case "FirstName": Item.Value = _traveller.firstName; break; case "LastName": Item.Value = _traveller.lastName; break; } } Result = Convert.ToInt16(DALHelper.ExecuteNonQuery(transaction, CommandType.StoredProcedure, "InsertTravellerProfile", paramData)); return(Result); } catch (Exception ex) { ErrorLogDL.InsertErrorLog(ex.Message, "RegisterTravellerUser"); throw ex; } }
public override void OnException(HttpActionExecutedContext actionExecutedContext) { if (actionExecutedContext.Exception is APIException) { APIException exceptionData = (APIException)actionExecutedContext.Exception; //The Response Message Set by the Action During Ececution var res = exceptionData.Message; //Define the Response Message HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.Accepted) { Content = new StringContent(exceptionData.ToString()), StatusCode = HttpStatusCode.Accepted, ReasonPhrase = res }; response.Headers.Add("ValidationMessageType", ((byte)exceptionData.MessageType).ToString()); //Create the Error Response actionExecutedContext.Response = response; string exception = actionExecutedContext.Exception.ToString(); ErrorLogDL.InsertErrorLog(exception, actionExecutedContext.Exception.Message.ToString()); } else { ///exception loging string exception = actionExecutedContext.Exception.ToString(); ErrorLogDL.InsertErrorLog(exception, actionExecutedContext.Exception.Message.ToString()); var res = actionExecutedContext.Exception.Message; HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent(res), StatusCode = HttpStatusCode.InternalServerError, ReasonPhrase = res }; //Create the Error Response actionExecutedContext.Response = response; } }
public string RegisterUser(User _user) { bool IsSuccess = true; string message = ""; IDbTransaction transaction = null; try { transaction = DALHelper.GetTransaction(); Int64 Result = _loginDL.RegisterUser(_user, transaction); if (Result > 0) { message = Result.ToString(); Email.SendMail("Dear " + _user.username + " your account has been created successfully", _user.email, "Account Registration"); } else { message = "unable to create user please contact provider support"; } } catch (SqlException ex) { IsSuccess = false; if (ex.Message.Contains("UNIQUE KEY")) { message = "User already registered"; } else { IsSuccess = false; ErrorLogDL.InsertErrorLog(ex.Message, "LoginBL : RegisterUser"); throw; } } finally { DALHelper.CloseDB(transaction, IsSuccess); } return(message); }
public string RegisterTravellerUser(Traveller _traveller) { bool IsSuccess = true; string message = ""; IDbTransaction transaction = null; try { transaction = DALHelper.GetTransaction(); Int64 resultID = _travellerDL.RegisterTravellerUser(_traveller, transaction); if (resultID > 0) { message = "Profile Updated Successfully"; } else { message = "error"; } } catch (SqlException ex) { IsSuccess = false; if (ex.Message.Contains("UNIQUE KEY")) { message = "Email already taken"; } else { IsSuccess = false; ErrorLogDL.InsertErrorLog(ex.Message, "TravellerBL:RegisterTravellerUser"); throw; } } finally { DALHelper.CloseDB(transaction, IsSuccess); } return(message); }
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 DataTable Login(User _user) { IDbConnection con = null; DataSet dsData = new DataSet(); DataTable fromdt = new DataTable(); Dictionary <string, object> dsResult = new Dictionary <string, object>(); try { con = DALHelper.GetConnection(); return(_loginDL.Login(_user, con)); } catch (Exception ex) { ErrorLogDL.InsertErrorLog(ex.Message, "LoginBL:Login"); throw; } finally { DALHelper.CloseDB(con); } }
public string UpdateHostelUser(Hostel _hostel) { bool IsSuccess = true; string message = ""; IDbTransaction transaction = null; try { transaction = DALHelper.GetTransaction(); Int64 resultID = _hostelDL.UpdateHostelUser(_hostel, transaction); if (resultID > 0) { message = "Hostel updated successfully"; } } catch (SqlException ex) { IsSuccess = false; if (ex.Message.Contains("UNIQUE KEY")) { message = "cannot insert hostel name with same name"; } else { IsSuccess = false; ErrorLogDL.InsertErrorLog(ex.Message, "HostelBL : UpdateHostelUser"); throw; } } finally { DALHelper.CloseDB(transaction, IsSuccess); } return(message); }
private void InsertGalery(DataTable dt, Int32 hostelId) { bool IsSuccess = true; IDbTransaction transaction = null; try { transaction = DALHelper.GetTransaction(); for (int i = 0; i < dt.Rows.Count; i++) { Int64 resultID = _hostelDL.AddGallery(dt.Rows[i], transaction, hostelId); } } catch (Exception ex) { ErrorLogDL.InsertErrorLog(ex.Message, "AddGallery"); IsSuccess = false; throw; } finally { DALHelper.CloseDB(transaction, IsSuccess); } }
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))); }