public HttpResponseMessage SyncAvatarTimestamp([FromBody] SyncDataDTO syncData) { LogRequest(syncData); if (!ModelState.IsValid || syncData == null) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } if (syncData.Contacts.Count > 0) { var user = new NeeoUser(syncData.Uid); try { var result = user.GetContactsAvatarTimestamp(syncData.MapModel()); return(Request.CreateResponse(HttpStatusCode.OK, result.ConvertAll((MapcontactStatusToContactAvatarTimestampDTO)))); } catch (ApplicationException appExp) { return(Request.CreateResponse(HttpStatusCode.InternalServerError)); } catch (Exception exp) { LogManager.CurrentInstance.ErrorLogger.LogError( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, exp.Message, exp); return(Request.CreateResponse(HttpStatusCode.InternalServerError)); } } return(Request.CreateResponse(HttpStatusCode.BadRequest)); }
/// <summary> /// Gets avatar timestamps details for the user's provided contacts. /// </summary> /// <param name="uID">A string containing the user id.</param> /// <param name="contacts">A string containing the ',' separated contacts.</param> /// <returns>A list containing user's contacts avatar timestamp.</returns> public List <ContactAvatarTimestamp> GetContactAvatarTimestamp(string uID, string contacts) { #region log user request and response /*********************************************** * To log user response ***********************************************/ if (_logRequestResponse) { LogManager.CurrentInstance.InfoLogger.LogInfo(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, System.Reflection.MethodBase.GetCurrentMethod().Name + "===>" + "Response==> User ID : " + uID + "- Contact List :" + contacts); } #endregion if (!NeeoUtility.IsNullOrEmpty(uID) && !NeeoUtility.IsNullOrEmpty(contacts)) { NeeoUser user = new NeeoUser(uID.Trim()); var result = user.GetContactsAvatarTimestamp(contacts); #region log user request and response /*********************************************** * To log user response ***********************************************/ if (_logRequestResponse) { LogManager.CurrentInstance.InfoLogger.LogInfo(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, System.Reflection.MethodBase.GetCurrentMethod().Name + "===>" + "Response==> User ID : " + uID + "- Contact List :" + JsonConvert.SerializeObject(result)); } #endregion return(result); } else { NeeoUtility.SetServiceResponseHeaders(CustomHttpStatusCode.InvalidArguments); } return(null); }
public HttpResponseMessage GetContactAvatarTimestamp(AvatarTimestampRequest request) { if (request != null) { request.uID = (request.uID != null) ? request.uID.Trim() : request.uID; #region log user request and response /*********************************************** * To log user response ***********************************************/ if (_logRequestResponse) { LogManager.CurrentInstance.InfoLogger.LogInfo( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, System.Reflection.MethodBase.GetCurrentMethod().Name + "===>" + "Response==> User ID : " + request.uID + "- Contact List :" + request.contacts); } #endregion //#region user authentication //IEnumerable<string> headerValues; //string keyFromClient = ""; //if (Request.Headers.TryGetValues("key", out headerValues)) //{ // keyFromClient = headerValues.First(); //} //if (NeeoUtility.AuthenticateUserRequest(getTimeStampRequest.uID, keyFromClient)) //{ // #endregion if (!NeeoUtility.IsNullOrEmpty(request.uID) && !NeeoUtility.IsNullOrEmpty(request.contacts)) { NeeoUser user = new NeeoUser(request.uID.Trim()); var result = user.GetContactsAvatarTimestamp(request.contacts); #region log user request and response /*********************************************** * To log user response ***********************************************/ if (_logRequestResponse) { LogManager.CurrentInstance.InfoLogger.LogInfo( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, System.Reflection.MethodBase.GetCurrentMethod().Name + "===>" + "Response==> User ID : " + request.uID + "- Contact List :" + JsonConvert.SerializeObject(result)); } #endregion return(Request.CreateResponse(HttpStatusCode.OK, result)); } } return(Request.CreateResponse(HttpStatusCode.BadRequest)); //} //else //{ // return Request.CreateResponse(HttpStatusCode.Unauthorized); //} }