public HttpResponseMessage Get([FromUri] GetGroupIconRequest request) { LogRequest(request); ulong temp = 0; if (NeeoUtility.IsNullOrEmpty(request.Uid) || !ulong.TryParse(request.Uid, out temp) || NeeoUtility.IsNullOrEmpty(request.gID)) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } else { request.Uid = request.Uid.Trim(); request.gID = request.gID.ToLower(); try { if (NeeoGroup.GroupIconExists(request.gID.ToLower())) { string url = NeeoUrlBuilder.BuildFileUrl(ConfigurationManager.AppSettings[NeeoConstants.FileServerUrl], request.gID, FileCategory.Group, MediaType.Image); return(RedirectServiceToUrl(url)); } else { return(Request.CreateResponse(HttpStatusCode.NotFound)); } } catch (Exception exception) { LogManager.CurrentInstance.ErrorLogger.LogError( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, System.Reflection.MethodBase.GetCurrentMethod().Name, exception); return(Request.CreateResponse(HttpStatusCode.InternalServerError)); } } }
/// <summary> /// /// </summary> /// <param name="uID"></param> /// <param name="gID"></param> /// <param name="reqType"></param> public void GetGroupIcon(string uID, string gID, string reqType = "GET") { #region log user request and response /*********************************************** * To log user request ***********************************************/ if (_logRequestResponse) { LogManager.CurrentInstance.InfoLogger.LogInfo( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, System.Reflection.MethodBase.GetCurrentMethod().Name + "===>" + "Request ===> senderID : " + uID + ", groupID : " + gID); } #endregion // #region Verify User //var request = OperationContext.Current.IncomingMessageProperties[HttpRequestMessageProperty.Name] as HttpRequestMessageProperty; //string keyFromClient = request.Headers["key"]; //if (NeeoUtility.AuthenticateUserRequest(uID, keyFromClient)) //{ // #endregion ulong temp = 0; if (NeeoUtility.IsNullOrEmpty(uID) || !ulong.TryParse(uID, out temp) || NeeoUtility.IsNullOrEmpty(gID)) { NeeoUtility.SetServiceResponseHeaders(CustomHttpStatusCode.InvalidArguments); } else { uID = uID.Trim(); gID = gID.ToLower(); try { if (!NeeoGroup.GroupIconExists(gID)) { NeeoUtility.SetServiceResponseHeaders((CustomHttpStatusCode)HttpStatusCode.NotFound); } else { string url = NeeoUrlBuilder.BuildFileUrl(ConfigurationManager.AppSettings[NeeoConstants.FileServerUrl], gID, FileCategory.Group, MediaType.Image); RedirectServiceToUrl(url); } } catch (Exception exception) { LogManager.CurrentInstance.ErrorLogger.LogError( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, System.Reflection.MethodBase.GetCurrentMethod().Name, exception); NeeoUtility.SetServiceResponseHeaders(CustomHttpStatusCode.ServerInternalError); } } //} //else //{ // NeeoUtility.SetServiceResponseHeaders((CustomHttpStatusCode)HttpStatusCode.Unauthorized); //} }