public bool AddHitCounter() { string IPClient = ""; string BrowserClient = ""; HttpBrowserCapabilities browser = HttpContext.Current.Request.Browser; BrowserClient = browser.Type + "/" + browser.Browser + "/" + browser.Version + "/" + browser.EcmaScriptVersion + "/" + browser.Platform; System.Web.HttpContext context = System.Web.HttpContext.Current; string ipAddress = context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if (!string.IsNullOrEmpty(ipAddress)) { string[] addresses = ipAddress.Split(','); if (addresses.Length != 0) { IPClient = addresses[0]; } } IPClient = context.Request.ServerVariables["REMOTE_ADDR"]; HitCounterEntity db = new HitCounterEntity(); db.Visitors.Add(new Visitor { visitTime = DateTime.Now, visitBrowser = BrowserClient, visitIp = IPClient, visitPage = context.Request.Url.AbsoluteUri.ToString() }); db.SaveChanges(); return(true); }
public void Delete(int _id, HitCounterEntity _db) { var model = _db.Contents.Find(_id); if (model != null && model.contentId > 0) { } }
public Content Add(Content _model, HitCounterEntity _db) { var model = new Content(); model = _model; _db.Contents.Add(model); _db.SaveChanges(); return(model); }