public IHttpActionResult SaveInformation(Models.InformationView info) { IList <Models.InformationView> info1 = null; if (!ModelState.IsValid) { return(BadRequest("Invalid data.")); } using (var ctx = new DemoEntities()) { ctx.InforMation.Add(new InforMation() { Id = info.Id, Name = info.Name, Address = info.Address, Mobile = info.Mobile, Email = info.Email }); ctx.SaveChanges(); info1 = ctx.InforMation.Select(s => new Models.InformationView() { Id = s.Id, Name = s.Name, Address = s.Address, Mobile = s.Mobile, Email = s.Email }).ToList <Models.InformationView>(); } return(Ok(info1)); }
public void InsertInfo(Models.InformationView Comment) { using (DbconnectionContext context = new DbconnectionContext()) { context.Comment.Add(Comment); context.SaveChanges(); } }