Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Servicestack validation
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Ermias  
View profile  
 More options Nov 10 2012, 12:53 am
From: Ermias <erm...@gmail.com>
Date: Fri, 9 Nov 2012 21:53:12 -0800 (PST)
Local: Sat, Nov 10 2012 12:53 am
Subject: Servicestack validation

I have a model

[Validator(typeof(ContractValidator))]
[Route("/contracts", "POST")]
public class Contract
{
public int ContractID{get; set;}
public string ContractNumber{get;set;}

}

I also have a validation class for the model above.

 public class ContractValidator : AbstractValidator<Contract>
    {
        public ContractValidator()
        {
            RuleFor(x => x.ContractNumber).Length(0, 10);
        }
    }

I also have a class to map a 'GET' request:

[Route("/contracts/{ContractID}", "GET")]
public class GetContract
  {
     public int ContractID { get; set; }
  }

...and a service:

public class ContractService : ServiceStack.ServiceInterface.Service
{
public object Get(GetContract request)
        {
            IContractRepository repository = new ContractRepository();

            return repository.GetById(request.ContractID);

        }

public object Post(Contract request)
        {
            IContractRepository repository = new ContractRepository();
            repository.Save(request);
            //return request;
        }

}

Now in my Razor view to edit a contract object I have

@inherits ViewPage<Contract>
.
.
.

But the problem is I'm getting the following error when I try to save and
there is a model validation error:

Unable to cast object of type
'ServiceStack.ServiceInterface.ServiceModel.ErrorResponse' to type
'DTO.Contract'

Can someone please let me know how to handle this?

Thanks,

Ermias.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »