/// <summary> /// Create /// </summary> /// <param name="fun_and_sp"></param> /// <returns>回傳新增的資料</returns> public IHttpActionResult PostAdd(TableInfoViewTableInfo fun_and_sp) { DateTime dNow = DateTime.Now; fun_and_sp.CreatedTime = dNow; fun_and_sp.UpdateTime = dNow; Exception exception = null; try { using (SQL_Programmability db = new SQL_Programmability()) { db.TableInfoViewTableInfo.Add(fun_and_sp); db.SaveChanges(); } } catch (Exception ex) { exception = ex; return(NotFound()); } if (exception == null) { return(Created(Url.Link("DefaultApi", new { id = fun_and_sp.Id }), fun_and_sp)); } else { return(NotFound()); } }
/// <summary> /// Update /// </summary> /// <param name="fun_and_sp"></param> /// <returns>回傳修改的資料</returns> public IHttpActionResult PutEdit(TableInfoViewTableInfo fun_and_sp) { DateTime dNow = DateTime.Now; TableInfoViewTableInfo new_fun_and_sp = new TableInfoViewTableInfo(); Exception exception = null; try { using (SQL_Programmability db = new SQL_Programmability()) { new_fun_and_sp = db.TableInfoViewTableInfo.Find(fun_and_sp.Id); if (new_fun_and_sp != null) { new_fun_and_sp.Name = fun_and_sp.Name; new_fun_and_sp.Execute = fun_and_sp.Execute; new_fun_and_sp.Content = fun_and_sp.Content; new_fun_and_sp.Remark = fun_and_sp.Remark; new_fun_and_sp.Tags = fun_and_sp.Tags; new_fun_and_sp.UpdateTime = dNow; db.SaveChanges(); } } } catch (Exception ex) { exception = ex; return(NotFound()); } if (exception == null && new_fun_and_sp != null) { return(Created(Url.Link("DefaultApi", new { id = new_fun_and_sp.Id }), new_fun_and_sp)); } else { return(NotFound()); } }