// GET: EventCategory/Delete/5 public ActionResult Delete(Nullable <int> id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Db db = new Db(DbServices.ConnectionString); EventCategory eventCategory = EventCategoryServices.Get(id.Value, db); if (eventCategory == null) { return(HttpNotFound()); } return(View(eventCategory)); }
internal static EventLog Log(int user, Db db, int categoryId, int sourceId, int statusId, XmlFormatterBase formatter, ILogErrorHandler handler = null) { EventLog eventLog = new EventLog(); eventLog.EventCategory = categoryId; eventLog.EventSource = sourceId; eventLog.EventStatus = statusId; eventLog.User = user; eventLog.Date = DateTime.Now; if (categoryId == (int)EventCategoryEnum.Uncategorized) { formatter = new UncategorizedXmlFormatter(EventCategoryEnum.Uncategorized.ToString(), formatter.Parameters); } eventLog.Parameters = formatter.ToString(); try { eventLog = EventLogServices.Insert(eventLog, db); } catch (Exception ex) { EventCategory category = EventCategoryServices.Get(categoryId, db); if (category != null) { eventLog.EventCategory = category.Id; } else { eventLog.EventCategory = (int)EventCategoryEnum.Uncategorized; } EventSource source = EventSourceServices.Get(sourceId, db); if (source != null) { eventLog.EventSource = source.Id; } else { eventLog.EventSource = (int)EventSourceEnum.Uncategorized; } EventStatus status = EventStatusServices.Get(statusId, db); if (status != null) { eventLog.EventStatus = status.Id; } else { eventLog.EventStatus = (int)EventStatusEnum.Error; } eventLog.Date = DateTime.Now; try { eventLog = EventLogServices.Insert(eventLog, db); } catch (Exception exx) { if (handler == null) { handler = new DefaultLogErrorHandler(); } handler.Handle(eventLog, exx); } } return(eventLog); }