public IHttpActionResult Post(TipCreate tip) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateTipService(); if (!service.CreateTip(tip)) { return(InternalServerError()); } return(Ok()); }
public bool CreateTip(TipCreate model) { var entity = new Tip() { Id = _userID.ToString(), TipId = model.TipId, TipText = model.TipText, Title = model.Title }; using (var ctx = new ApplicationDbContext()) { ctx.Tips.Add(entity); return(ctx.SaveChanges() == 1); } }