public IHttpActionResult Post(TitleModel model, int userId) { try { int result = _service.Insert(model, userId); return(Ok(result)); } catch (Exception ex) { return(BadRequest(ex.Message.ToString())); } }
public ActionResult Create() { TitleVM[] datas = ClassConvert <TitleVM> .Process(Request.Form); var result = _titleService.Insert(datas[0]); if (result.ResultType != OperationResultType.Success) { return(Json(new { error = result.ResultType.GetDescription(), total = 1, data = this._titleService.Titles.ToArray() })); } else { Title[] results = this._titleService.Titles.ToArray(); return(Json(new { total = 1, data = new[] { results[results.Length - 1] } })); } }