public HttpResponseMessage Get(int id)
 {
     try
     {
         var cardType = _loyaltyCardTypeService.GetById(id);
         return(Request.CreateResponse(HttpStatusCode.OK, cardType != null ? new LoyaltyCardTypeModel(cardType):null));
     }
     catch (Exception e)
     {
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, e));
     }
 }
Esempio n. 2
0
 public JsonMessageModel Put(ConfigModel model, string access_token = null)
 {
     if (!AuthorizeAccessToken(access_token).success)
     {
         return(AuthorizeAccessToken(access_token));
     }
     try
     {
         if (!ModelState.IsValid)
         {
             return new JsonMessageModel {
                        success = false, statusCode = (int)HttpStatusCode.ExpectationFailed, message = "Model state not Valid"
             }
         }
         ;
         var id     = model.GetType().GetProperty("Id").GetValue(model);
         var config = _configService.GetById(Int32.Parse(id.ToString()));
         if (config == null)
         {
             return new JsonMessageModel {
                        success = false, statusCode = (int)HttpStatusCode.ExpectationFailed, message = "Entity Not Found!"
             }
         }
         ;
         model.CreatedOn = config.CreatedOn;
         config          = model.ToEnity();
         _configService.Update(config);
         return(new JsonMessageModel {
             success = true, statusCode = (int)HttpStatusCode.OK, message = "New Config is updated!", data = config.Id
         });
     }
     catch (Exception e)
     {
         return(ExceptionReturnMessage(e));
     }
 }