Example #1
0
 public HttpResponseMessage Post([FromBody] SenderViewModel model)
 {
     if (ModelState.IsValid)
     {
         var sen = new Sender()
         {
             //SenderId = model.SenderId,
             ForName1       = model.ForName1,
             ForName2       = model.ForName2,
             AddressLine1   = model.AddressLine1,
             AddressLine2   = model.AddressLine2,
             AddressLine3   = model.AddressLine3,
             Country        = model.Country,
             Email          = model.Email,
             Mobile         = model.Mobile,
             HMRCPassword   = model.HMRCPassword,
             HMRCUserId     = model.HMRCUserId,
             Postcode       = model.Postcode,
             SenderPassword = model.SenderPassword,
             SurName        = model.SurName,
             Telephone      = model.Telephone,
             Title          = model.Title,
             Type           = model.Type
         };
         var sucess = _senderService.Save(sen);
         if (sucess)
         {
             var msg = new HttpResponseMessage(HttpStatusCode.Created);
             return(msg);
         }
         else
         {
             throw new HttpResponseException(HttpStatusCode.Conflict);
         }
     }
     else
     {
         throw new HttpResponseException(new HttpResponseMessage
         {
             StatusCode   = HttpStatusCode.BadRequest,
             ReasonPhrase = "Model validation failed"
         });
     }
 }