public IHttpActionResult PosttypeFactory(TypeFactoryViewModel Type_FactoryView_Model)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            typeFactory typeFactory_db;
            try
            {
                typeFactory_db = new typeFactory { Id = Type_FactoryView_Model.Id, No = Type_FactoryView_Model.No, Name = Type_FactoryView_Model.Name };
                db.typeFactories.Add(typeFactory_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 = typeFactory_db.Id }, ToViewModel(typeFactory_db));
        }
 private TypeFactoryViewModel ToViewModel(typeFactory c)
 {
     return new TypeFactoryViewModel { Id = c.Id, No = c.No, Name = c.Name, TimestampString = Convert.ToBase64String(c.Timestamp) };
 }