Exemplo n.º 1
0
 private bool IsIDValid(int id)
 {
     if (!_contactContext.Contacts.Any(c => c.ID == id))
     {
         throw ClientErrors.InvalidId();
     }
     else
     {
         return(true);
     }
 }
Exemplo n.º 2
0
        public static void ValidateRequest(Contact contact)
        {
            Regex emailRegex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
            Match match      = emailRegex.Match(contact.EmailID);

            if (!match.Success)
            {
                throw ClientErrors.InvalidEmailId();
            }

            if (contact.FirstName.Length > 50)
            {
                throw ClientErrors.InvalidFirstName();
            }

            if (contact.LastName.Length > 50)
            {
                throw ClientErrors.InvalidLastName();
            }
        }
Exemplo n.º 3
0
 void IObserver <DataChanged <IClient> > .OnError(Exception error)
 {
     ClientErrors.Enqueue(error);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Вызов событий об ошибках
 /// </summary>
 /// <param name="type">тип ошибки</param>
 /// <param name="message">сообщение об ошибке</param>
 internal void CallErrorClient(ClientErrorType type, string message)
 {
     Task.Factory.StartNew(() => ClientErrors?.Invoke(this, new ErrorClientArgs(type, message)));
 }
Exemplo n.º 5
0
 private void BadRequest(HttpActionContext actionContext)
 {
     Trace.TraceError("Trottle Attribute sending error response: 400. Bad request, since the access_token is not found in the request header");
     actionContext.Response = ClientErrors.InvalidJson(actionContext);
 }
Exemplo n.º 6
0
 private void Forbidden(HttpActionContext actionContext)
 {
     Trace.TraceError("Trottle Attribute sending error response: 403. Application Rate Limit Exceeded.");
     actionContext.Response = ClientErrors.RateLimitExceeded(actionContext);
 }
Exemplo n.º 7
0
 private void BadRequest(HttpActionContext actionContext)
 {
     Trace.TraceWarning("Basic Authorization Attribute sending error response: 400. Access token not present");
     actionContext.Response = ClientErrors.InvalidJson(actionContext);
 }
Exemplo n.º 8
0
 private void Forbidden(HttpActionContext actionContext)
 {
     Trace.TraceWarning("Basic Authorization Attribute sending error response: 403. No valid session for the token.");
     actionContext.Response = ClientErrors.InvalidToken(actionContext);
 }