public static FaultException <ServiceErrorResponse> Generar(string strMensaje) { dynamic serviceErrorResponse = new ServiceErrorResponse(); serviceErrorResponse.Message = strMensaje; throw new FaultException <ServiceErrorResponse>(serviceErrorResponse, new FaultReason(strMensaje)); }
public JsonResult CalculateBrutoNetto(dynamic parameters) { ServiceResponse response = default(ServiceResponse); using (Session session = ApplicationModel.Current.CreateSession(new SecurityToken(this.HttpContext.Request.Url.Host, this.HttpContext.User.Identity.Name))) { try { HttpRequestAgent connector = new HttpRequestAgent(); string value = connector.Post("https://brutnet.attentia.be/GetBrutoNettoBerekening?onlyValidate=true", parameters); //string value = "{ \"Bruto\": \"2500.0\", \"Netto\": \"1250.00\" }"; if (string.IsNullOrEmpty(value)) { HttpContext.Response.StatusCode = (int)HttpStatusCode.NotFound; } ResponseStatus status = string.IsNullOrEmpty(value) ? ResponseStatus.NO_DATA : ResponseStatus.OK; response = new ServiceDataResponse(RestVersion0100Controller.API_VERSION, status, value); } catch (Exception ex) { HttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest; response = new ServiceErrorResponse(RestVersion0100Controller.API_VERSION, ResponseStatus.ERROR, new ServiceError(ex)); } } return(this.Json(response)); }
public async Task <JsonResult> SignUpUser(OAuth2UserIdentity userIdentity) { ServiceResponse response = default(ServiceResponse); using (Session session = ApplicationModel.Current.CreateSession(new SecurityToken(this.HttpContext.Request.Url.Host, this.HttpContext.User.Identity.Name))) { try { IDataPortal portal = DependencyInjection.Get <IDataPortal>(); OAuth2UserIdentity value = portal.SignUpUser(userIdentity); // Set the status on HTTP and response level. if (value == null) { HttpContext.Response.StatusCode = (int)HttpStatusCode.NotFound; } ResponseStatus status = value == null ? ResponseStatus.NO_DATA : ResponseStatus.OK; response = new ServiceDataResponse(RestVersion0100Controller.API_VERSION, status, value); } catch (Exception ex) { HttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest; response = new ServiceErrorResponse(RestVersion0100Controller.API_VERSION, ResponseStatus.ERROR, new ServiceError(ex)); } } return(this.Json(response)); }
public async Task <JsonResult> GetUserProfile() { ServiceResponse response = default(ServiceResponse); using (Session session = ApplicationModel.Current.CreateSession(new SecurityToken(this.HttpContext.Request.Url.Host, this.HttpContext.User.Identity.Name))) { try { string value = "HELLO WORLD 2.0"; // Set the status on HTTP and response level. if (value == null) { HttpContext.Response.StatusCode = (int)HttpStatusCode.NotFound; } ResponseStatus status = value == null ? ResponseStatus.NO_DATA : ResponseStatus.OK; response = new ServiceDataResponse(RestVersion0100Controller.API_VERSION, status, value); } catch (Exception ex) { response = new ServiceErrorResponse(RestVersion0100Controller.API_VERSION, ResponseStatus.ERROR, new ServiceError(ex)); } } return(this.Json(response, JsonRequestBehavior.AllowGet)); }
public IActionResult DeleteTaxonomy([FromRoute] int id) { try { _taxonomyUseCase.ExecuteDelete(id); return(Ok()); } catch (InvalidOperationException e) { LoggingHandler.LogError(e.Message); LoggingHandler.LogError(e.StackTrace); return(BadRequest( new ErrorResponse($"Error deleting taxonomy") { Status = "Bad request", Errors = new List <string> { $"An error occurred attempting to delete taxonomy {id}: {e.Message}" } })); } catch (UseCaseException e) { return(BadRequest(e)); } catch (ServiceTaxonomyExistsException ex) { var errorResponse = new ServiceErrorResponse { ErrorMessage = ex.DevErrorMessage, Services = ex.Services }; return(BadRequest(errorResponse)); } }
private ServiceErrorResponse BuildErrorResponse(IServiceRequest request) { var response = new ServiceErrorResponse() { ServiceName = request.ServiceName, RequestId = request.RequestId, Status = false, ErrorCode = 99, Message = String.Format("Error while handling request for service: {0}", request.ServiceName) }; return(response); }
public static ServiceErrorResponse UnAuthorized() { var error = new ServiceErrorResponse { StatusCode = HttpStatusCode.Forbidden, Error = new ServiceError { Code = ServiceErrorCodes.Unauthorized, Message = "User is not authorized.", Target = "todoItem" } }; return(error); }
public static ServiceErrorResponse AccessDenied() { var error = new ServiceErrorResponse { StatusCode = HttpStatusCode.Forbidden, Error = new ServiceError { Code = ServiceErrorCodes.Forbidden, Message = $"No access to the requested resource.", Target = "toDoTask" } }; return(error); }
public static ServiceErrorResponse IncorrectPassword() { var error = new ServiceErrorResponse { StatusCode = HttpStatusCode.BadRequest, Error = new ServiceError { Code = ServiceErrorCodes.ValidationError, Message = $"Wrong password entered.", Target = "password" } }; return(error); }
public static ServiceErrorResponse InvalidRouteParameter(string target) { var error = new ServiceErrorResponse { StatusCode = HttpStatusCode.BadRequest, Error = new ServiceError { Code = ServiceErrorCodes.BadRequest, Message = "Route parameter is null or has inappropriate form.", Target = target } }; return(error); }
public static ServiceErrorResponse NoSuchObject(string target, string message) { var error = new ServiceErrorResponse { StatusCode = HttpStatusCode.NotFound, Error = new ServiceError { Code = ServiceErrorCodes.NotFound, Message = message, Target = target } }; return(error); }
public static ServiceErrorResponse InvalidClaims(string target) { var error = new ServiceErrorResponse { StatusCode = HttpStatusCode.BadRequest, Error = new ServiceError { Code = ServiceErrorCodes.BadRequest, Message = "JWT has invalid claims", Target = target } }; return(error); }
public static ServiceErrorResponse InvalidQuery(string target) { var error = new ServiceErrorResponse { StatusCode = HttpStatusCode.BadRequest, Error = new ServiceError { Code = ServiceErrorCodes.BadRequest, Message = "Request query parameters are invalid.", Target = target } }; return(error); }
public static ServiceErrorResponse ToDoAlreadyExists(string target) { var error = new ServiceErrorResponse { StatusCode = HttpStatusCode.BadRequest, Error = new ServiceError { Code = ServiceErrorCodes.Forbidden, Message = "ToDo already exists.", Target = target } }; return(error); }
public static ServiceErrorResponse ValidationError(string target, string message) { var error = new ServiceErrorResponse { StatusCode = HttpStatusCode.BadRequest, Error = new ServiceError { Code = ServiceErrorCodes.ValidationError, Message = message, Target = target } }; return(error); }
public static ServiceErrorResponse AuthIsNotConfirmed(string target) { var error = new ServiceErrorResponse { StatusCode = HttpStatusCode.Unauthorized, Error = new ServiceError { Code = ServiceErrorCodes.Forbidden, Message = "Authorization forbidden", Target = target } }; return(error); }
public static ServiceErrorResponse Forbidden() { var error = new ServiceErrorResponse { StatusCode = HttpStatusCode.Forbidden, Error = new ServiceError { Code = ServiceErrorCodes.Forbidden, Message = "Access is forbidden.", Target = "user" } }; return(error); }
public static ServiceErrorResponse BodyIsMissingOrUncorrect(string target) { var error = new ServiceErrorResponse { StatusCode = HttpStatusCode.BadRequest, Error = new ServiceError { Code = ServiceErrorCodes.BadRequest, Message = "Request body is empty or uncorrect.", Target = target } }; return(error); }
public static ServiceErrorResponse Unauthenticated() { var error = new ServiceErrorResponse { StatusCode = HttpStatusCode.Unauthorized, Error = new ServiceError { Code = ServiceErrorCodes.Unauthorized, Message = "User is not unauthorized.", Target = "user" } }; return(error); }
public static ServiceErrorResponse UserIdIsNull() { var error = new ServiceErrorResponse { StatusCode = HttpStatusCode.BadRequest, Error = new ServiceError { Code = ServiceErrorCodes.BadRequest, Message = "User Id is null.", Target = "user" } }; return(error); }
public static ServiceErrorResponse NotEnoughUserData() { var error = new ServiceErrorResponse { StatusCode = HttpStatusCode.BadRequest, Error = new ServiceError { Code = ServiceErrorCodes.ValidationError, Message = $"Username and / or password are not entered.", Target = "user" } }; return(error); }
public static ServiceErrorResponse ConflictLogin(string login) { var error = new ServiceErrorResponse { StatusCode = HttpStatusCode.Conflict, Error = new ServiceError { Code = ServiceErrorCodes.Conflict, Message = $"User with such login: \"{login}\" already exist.", Target = "user" } }; return(error); }
public static ServiceErrorResponse InvalidImageData(string target) { var error = new ServiceErrorResponse { StatusCode = HttpStatusCode.BadRequest, Error = new ServiceError { Code = ServiceErrorCodes.BadRequest, Message = "Image must has PNG or JPG format and be less than 512 KB.", Target = target } }; return(error); }
public static ServiceErrorResponse InvalidCredentialsError(string target) { var error = new ServiceErrorResponse { StatusCode = HttpStatusCode.BadRequest, Error = new ServiceError { Code = ServiceErrorCodes.InvalidCredentials, Message = "Username or password is incorrect.", Target = target } }; return(error); }
public static ServiceErrorResponse UserNotFound() { var error = new ServiceErrorResponse { StatusCode = HttpStatusCode.BadRequest, Error = new ServiceError { Code = ServiceErrorCodes.ValidationError, Message = $"There is no user with this login or password.", Target = "user" } }; return(error); }
public static ServiceErrorResponse UnauthorizedError(string target) { var error = new ServiceErrorResponse { StatusCode = HttpStatusCode.BadRequest, Error = new ServiceError { Code = ServiceErrorCodes.Unauthorized, Message = "You must be authorized. Access prohibited.", Target = target } }; return(error); }
public static ServiceErrorResponse BodyIsMissing(string target) { var error = new ServiceErrorResponse { StatusCode = HttpStatusCode.BadRequest, Error = new ServiceError { Code = ServiceErrorCodes.BadRequest, Message = "Request body is empty or has inappropriate form.", Target = target } }; return(error); }
public static ServiceErrorResponse TodoNotFound(string activityId) { if (activityId == null) { throw new ArgumentNullException(nameof(activityId)); } var error = new ServiceErrorResponse { StatusCode = HttpStatusCode.NotFound, Error = new ServiceError { Code = ServiceErrorCodes.NotFound, Message = $"An activity with \"{activityId}\" not found.", Target = "activity" } }; return(error); }
public static ServiceErrorResponse ItemNotFound(string itemId) { if (itemId == null) { throw new ArgumentNullException(nameof(itemId)); } var error = new ServiceErrorResponse { StatusCode = HttpStatusCode.NotFound, Error = new ServiceError { Code = ServiceErrorCodes.NotFound, Message = $"A ToDo item with \"{itemId}\" not found.", Target = "ToDoItem" } }; return(error); }
public static ServiceErrorResponse UserNameAlreadyExists(string userName) { if (userName == null) { throw new ArgumentNullException(nameof(userName)); } var error = new ServiceErrorResponse { StatusCode = HttpStatusCode.BadRequest, Error = new ServiceError { Code = ServiceErrorCodes.BadRequest, Message = $"User \"{userName}\" already exists.", Target = userName } }; return(error); }
public int IndexOf(ServiceErrorResponse value) { return a.IndexOf(value); }
public bool Contains(ServiceErrorResponse value) { return a.Contains(value); }
public void Remove(ServiceErrorResponse value) { a.Remove(value); }
public int Add(ServiceErrorResponse value) { return a.Add(value); }
public void Insert(int index, ServiceErrorResponse value) { a.Insert(index, value); }