public IHttpActionResult PostcatPay(CatPayViewModel Cat_PayView_Model)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            catPay catPay_db;
            try
            {
                catPay_db = new catPay { Id = Cat_PayView_Model.Id, No = Cat_PayView_Model.No, Name = Cat_PayView_Model.Name };
                db.catPays.Add(catPay_db);
                db.SaveChanges();
            }
            catch (DbEntityValidationException ex)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.InternalServerError, "DbEntityValidationException:" + ex.Message));
            }
            catch (Exception ex)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }

            return CreatedAtRoute("DefaultApi", new { id = catPay_db.Id }, ToViewModel(catPay_db));
        }
 private CatPayViewModel ToViewModel(catPay c)
 {
     return new CatPayViewModel { Id = c.Id, No = c.No, Name = c.Name, TimestampString = Convert.ToBase64String(c.Timestamp) };
 }