/// <summary> /// Gets notification authentication. /// </summary> /// <param name="id"></param> /// <param name="token"></param> /// <returns>User</returns> public async Task <IHttpActionResult> GetUserAuth() { try { string token = _commonOperationsManager.GetCookieValue(Request, ConfigurationManager.AppSettings["UserTokenCookieName"]); var notificationsAuth = await _notificationsManager.GetNotificationsAuth(token); return(Ok(notificationsAuth)); } catch (AuthenticationException) { return(BadRequest("Authentication was not approved")); } catch (Exception e) { return(InternalServerError(e)); } }
public async Task <IHttpActionResult> AddPost() { try { var httpRequest = HttpContext.Current.Request; string token = _commonOperationsManager.GetCookieValue(Request, "authToken"); string picPath = ""; if (httpRequest.Files["Pic"] != null) { picPath = HttpContext.Current.Server.MapPath("~/" + httpRequest.Files["Pic"].FileName); } var postToReturn = await _postsManager.Add(httpRequest, token, picPath); return(Ok(postToReturn)); } catch (Exception e) { return(InternalServerError()); } }
/// <summary> /// Gets all the users except the user associated with the specified Id. /// </summary> /// <param name="userId"></param> /// <param name="usersToShow"></param> /// <returns></returns> public async Task <IHttpActionResult> GetUsers() { try { string token = _commonOperationsManager.GetCookieValue(Request, "authToken"); var usersToReturn = await _usersManager.GetUsers(token); return(Ok(usersToReturn)); } catch (Exception e) { return(InternalServerError()); } }