public IHttpActionResult PutLog_Table(int id, Log_Table log_Table) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != log_Table.Log_Table_Id) { return(BadRequest()); } db.Entry(log_Table).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!Log_TableExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
private void CanSession_Click(object sender, RoutedEventArgs e) { current_transaction.Status = "Cancelled"; current_transaction.Time_Close = System.DateTime.Now; Log_Table log = new Log_Table(current_transaction); log.Insert(); Transaction_Table.Delete(current_transaction.Transaction_Id); this.Frame.Navigate(typeof(UserCancelFeedback)); }
private void CanSession_Click(object sender, RoutedEventArgs e) { App.transaction_table.Status = "Cancelled"; App.transaction_table.Time_Close = System.DateTime.Now; Log_Table log = new Log_Table(App.transaction_table); log.Insert(); Transaction_Table.Delete(App.transaction_table.Transaction_Id); this.Frame.Navigate(typeof(VolunteerHome)); }
public IHttpActionResult PostLog_Table(Log_Table log_Table) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Log_Table.Add(log_Table); db.SaveChanges(); return(CreatedAtRoute("route1", new { id = log_Table.Log_Table_Id }, log_Table)); }
public IHttpActionResult GetLog_Table(int id) { Log_Table log_Table = db.Log_Table.Find(id); if (log_Table == null) { return(NotFound()); } DTO_Log_Table dlt = new DTO_Log_Table(); log_Table.ConvertToDTO(dlt); return(Ok(dlt)); }
public IHttpActionResult DeleteLog_Table(int id) { Log_Table log_Table = db.Log_Table.Find(id); if (log_Table == null) { return(NotFound()); } db.Log_Table.Remove(log_Table); db.SaveChanges(); return(Ok(log_Table)); }
public void CreateTable <T>(T t) where T : class { try { string tableID = PrimaryKeyHelper.MakePrimaryKey(PrimaryKeyHelper.PrimaryKeyType.Table, PrimaryKeyHelper.PrimaryKeyLen.V1); string tableName = typeof(T).Name; string primaryKey = "SystemID"; string Account = "sys"; string NickName = "系统生成"; Log_Table entity = new Log_Table(); entity.TableID = tableID; entity.TableName = tableName; entity.PrimaryKey = primaryKey; entity.Account = Account; entity.NickName = NickName; List <Log_TableDetails> lists = new List <Log_TableDetails>(); PropertyInfo[] pi = typeof(T).GetProperties(); foreach (PropertyInfo p in pi) { string columnName = p.Name.ToString(); //得到属性的名称 Type columnType = p.PropertyType; //得到属性的类型 if (p.PropertyType.IsGenericType && p.PropertyType.GetGenericTypeDefinition() == typeof(Nullable <>)) { columnType = p.PropertyType.GetGenericArguments()[0]; } lists.Add(new Log_TableDetails() { TableID = tableID, TableName = tableName, ColumnName = columnName, ColumnDataType = columnType.Name, Account = Account, NickName = NickName, }); } TableService.SaveTable(entity); TableDetailsService.SaveTableDetails(lists); } catch (Exception ex) { throw new Exception(ex.Message); } }
private Log_Table SaveTable(string tableName) { try { string tableID = CreateTableID(); Log_Table entity = new Log_Table(); entity.TableID = tableID; entity.TableName = tableName; entity.PrimaryKey = PrimaryKey; entity.Account = Account; entity.NickName = NickName; List <Log_TableDetails> lists = new List <Log_TableDetails>(); PropertyInfo[] pi = typeof(T).GetProperties(); foreach (PropertyInfo p in pi) { string columnName = p.Name.ToString(); //得到属性的名称 Type columnType = p.PropertyType; //得到属性的类型 if (p.PropertyType.IsGenericType && p.PropertyType.GetGenericTypeDefinition() == typeof(Nullable <>)) { columnType = p.PropertyType.GetGenericArguments()[0]; } lists.Add(new Log_TableDetails() { TableID = tableID, TableName = tableName, ColumnName = columnName, ColumnDataType = columnType.Name, Account = Account, NickName = NickName, }); } TableService.SaveTable(entity); TableDetailsService.SaveTableDetails(lists); return(entity); } catch (Exception ex) { throw new Exception(ex.Message); } }