/// <summary> /// 取消关注 /// </summary> /// <param name="id"></param> /// <param name="UserID"></param> /// <returns></returns> public int DeleSFollow(int id, int UserID) { LCollection a = db.LCollection.FirstOrDefault(p => p.LeaseID == id && p.UserID == UserID); db.LCollection.Remove(a); return(db.SaveChanges()); }
/// <summary> /// 添加关注 /// </summary> /// <param name="id"></param> /// <param name="UserID"></param> /// <returns></returns> public static int AddSFollow(int id, int UserID) { LCollection sc = new LCollection() { UserID = UserID, LeaseID = id }; db.LCollection.Add(sc); return(db.SaveChanges()); }
public static void ValidResponse <T, U>(T request, U response, UserInformation userInformation) where T : class { if ((response == null)) { // Set trạng thái xử lý cho client userInformation.OperationStatus = ApplicationConstant.OperationStatus.NoResponse.layGiaTri(); // Ghi log LLogging.WriteLog(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), LLogging.LogType.SYS, "No response from Server"); throw new CustomException("M.ResponseMessage.Common.NoResponse", null); } // Nếu có thông tin trả về else { // Kiểm tra ResponseId if (response.GetType().GetProperty("ResponseId").GetValue(response, null).ToString() != request.GetType().GetProperty("RequestId").GetValue(request, null).ToString()) { // Ghi log LLogging.WriteLog(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), LLogging.LogType.SYS, "ResponseId and RequestId do not match"); throw new CustomException("M.ResponseMessage.Common.ResponseIdIsNotMatch", null); } // Kiểm tra ResposeSecurityKey if (response.GetType().GetProperty("ResponseSecurityKey").GetValue(response, null).ToString() != userInformation.ResponsetSecurityKey) { // Ghi log LLogging.WriteLog(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), LLogging.LogType.SYS, "Invalid SecurityResponseKey"); throw new CustomException("M.ResponseMessage.Common.InvalidSecurityResponseKey", null); } //// Kiểm tra ResponseMessage //if (response.GetType().GetProperty("ResponseMessage").GetValue(response, null) != null && // response.GetType().GetProperty("ResponseMessage").GetValue(response, null).ToString() == ApplicationConstant.CommonResponseMessage.M_ResponseMessage_Common_InvalidOrExpiredOperationSession.layGiaTri()) //{ // // Ghi log // LLogging.WriteLog(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), LLogging.LogType.SYS, response.GetType().GetProperty("ResponseMessage").GetValue(response, null).ToString()); // throw new CustomException("M.ResponseMessage.Common.InvalidOrExpiredOperationSession", null); //} // Nếu không thành công if (response.GetType().GetProperty("ResponseStatus").GetValue(response, null).ToString() == ApplicationConstant.ResponseStatus.KHONG_THANH_CONG.ToString()) { object responseMessage = response.GetType().GetProperty("ResponseMessage").GetValue(response, null); byte[] exception = (byte[])response.GetType().GetProperty("ExceptionObject").GetValue(response, null); if ((responseMessage != null) && (responseMessage.ToString() == ApplicationConstant.CommonResponseMessage.M_ResponseMessage_Common_InvalidOrExpiredOperationSession.layGiaTri())) { // Set trạng thái xử lý cho client userInformation.OperationStatus = ApplicationConstant.OperationStatus.InvalidOrExpiredOperationSession.layGiaTri(); // Ghi log LLogging.WriteLog(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), LLogging.LogType.SYS, response.GetType().GetProperty("ResponseMessage").GetValue(response, null).ToString()); throw new CustomException(responseMessage.ToString(), null); } else if ((responseMessage != null) && (responseMessage.ToString() == ApplicationConstant.CommonResponseMessage.M_ResponseMessage_Common_LoseSession.layGiaTri())) { // Set trạng thái xử lý cho client userInformation.OperationStatus = ApplicationConstant.OperationStatus.LoseSession.layGiaTri(); // Ghi log LLogging.WriteLog(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), LLogging.LogType.SYS, response.GetType().GetProperty("ResponseMessage").GetValue(response, null).ToString()); throw new CustomException(responseMessage.ToString(), null); } else if ((responseMessage != null) && (responseMessage.ToString() == ApplicationConstant.CommonResponseMessage.M_ResponseMessage_Common_InvalidWorkingDay.layGiaTri())) { // Set trạng thái xử lý cho client userInformation.OperationStatus = ApplicationConstant.OperationStatus.InvalidWorkingDay.layGiaTri(); // Ghi log LLogging.WriteLog(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), LLogging.LogType.SYS, response.GetType().GetProperty("ResponseMessage").GetValue(response, null).ToString()); throw new CustomException(responseMessage.ToString(), null); } /* * else if ((responseMessage != null) && (responseMessage.ToString() == ApplicationConstant.LoginResponseMessage.M_ResponseMessage_Login_LoadUserRolesFailed.layGiaTri())) * { * // Ghi log * LLogging.WriteLog(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), LLogging.LogType.SYS, response.GetType().GetProperty("ResponseMessage").GetValue(response, null).ToString()); * throw new CustomException(responseMessage.ToString(), null); * } * else if ((responseMessage != null) && (responseMessage.ToString() == ApplicationConstant.LoginResponseMessage.M_ResponseMessage_Login_LoadUserBranchesFailed.layGiaTri())) * { * // Ghi log * LLogging.WriteLog(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), LLogging.LogType.SYS, response.GetType().GetProperty("ResponseMessage").GetValue(response, null).ToString()); * throw new CustomException(responseMessage.ToString(), null); * } * else if ((responseMessage != null) && (responseMessage.ToString() == ApplicationConstant.LoginResponseMessage.M_ResponseMessage_Login_YeuCauDoiMatKhauLanDau.layGiaTri())) * { * // Ghi log * LLogging.WriteLog(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), LLogging.LogType.SYS, response.GetType().GetProperty("ResponseMessage").GetValue(response, null).ToString()); * throw new CustomException(responseMessage.ToString(), null); * } */ else if ((responseMessage != null) && (exception != null)) { // Ghi log LLogging.WriteLog(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), LLogging.LogType.SYS, response.GetType().GetProperty("ResponseMessage").GetValue(response, null).ToString()); throw new CustomException(responseMessage.ToString(), exception != null ? LCollection.Deserialize(exception) : null); } /* * else * { * // Ghi log * LLogging.WriteLog(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), LLogging.LogType.SYS, "M.ResponseMessage.Common.KhongThanhCong"); * //throw new CustomException("M.ResponseMessage.Common.KhongThanhCong", null); * //throw new CustomException("M.ResponseMessage.Common.KhongThanhCong", LCollection.Deserialize(response.GetType().GetProperty("ExceptionObject").GetValue(response, null))); * } */ } } }