public int Post(dnn_YourCompany_LogEntry logEntry) { var transactionOptions = new System.Transactions.TransactionOptions(); transactionOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted; int newItemid = 0; using (var transactionScope = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required, transactionOptions)) { using (dotnetnukeEntities db = new dotnetnukeEntities()) { try { db.Configuration.ProxyCreationEnabled = false; logEntry.CreatedDate = DateTime.Now; logEntry.EntryDate = DateTime.Now; logEntry.ModuleID = 380; db.Set <dnn_YourCompany_LogEntry>().Add(logEntry); db.SaveChanges(); newItemid = logEntry.ItemID; } catch (Exception e) { string error = e.Message; } } transactionScope.Complete(); } return(newItemid); }
public void Delete(int itemid) { var transactionOptions = new System.Transactions.TransactionOptions(); transactionOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted; using (var transactionScope = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required, transactionOptions)) { using (dotnetnukeEntities db = new dotnetnukeEntities()) { try { dnn_YourCompany_LogEntry _logEntry = db.dnn_YourCompany_LogEntry .Where(e => e.ItemID == itemid).FirstOrDefault(); if (_logEntry != null) { db.Configuration.ProxyCreationEnabled = false; db.Set <dnn_YourCompany_LogEntry>().Remove(_logEntry); db.SaveChanges(); } } catch (Exception e) { string error = e.Message; } } transactionScope.Complete(); } }
public void Put(dnn_YourCompany_LogEntry logEntry) { var transactionOptions = new System.Transactions.TransactionOptions(); transactionOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted; using (var transactionScope = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required, transactionOptions)) { using (dotnetnukeEntities db = new dotnetnukeEntities()) { try { dnn_YourCompany_LogEntry _logEntry = db.dnn_YourCompany_LogEntry .Where(e => e.ItemID == logEntry.ItemID).FirstOrDefault(); if (_logEntry != null) { db.Configuration.ProxyCreationEnabled = false; if (_logEntry.EntryDate == null) { _logEntry.EntryDate = DateTime.Now; } _logEntry.EntryDate = logEntry.EntryDate; _logEntry.Entry = logEntry.Entry; db.SaveChanges(); } else { Post(logEntry); } } catch (Exception e) { string error = e.Message; } } transactionScope.Complete(); } }
// PUT api/values/5 public void Put([FromBody] dnn_YourCompany_LogEntry logEntry) { repository.Put(logEntry); }
// POST api/values public int Post([FromBody] dnn_YourCompany_LogEntry logEntry) { return(repository.Post(logEntry)); }