Ejemplo n.º 1
0
        public void Create(VisitorStatisticModel model)
        {
            var data = Connect_Enttity.VisitorStatistics.FirstOrDefault(x => x.ID == model.ID);

            if (data == null)
            {
                var entity = new VisitorStatistic();
                entity.ID          = model.ID;
                entity.VisitedDate = model.VisitedDate;
                entity.IPAddress   = model.IPAddress;

                Connect_Enttity.VisitorStatistics.Add(entity);
                Connect_Enttity.SaveChanges();
                Dispose();
            }
        }
Ejemplo n.º 2
0
 public HttpResponseMessage Post(HttpRequestMessage request, VisitorStatisticViewModel visitorStatisticVm)
 {
     return(CreateHttpResponse(request, () =>
     {
         HttpResponseMessage response = null;
         if (!ModelState.IsValid)
         {
             request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
         }
         else
         {
             VisitorStatistic newVisitorStatistic = new VisitorStatistic();
             newVisitorStatistic.UpdateVisitorStatistic(visitorStatisticVm);
             var category = _visitorStatisticService.Add(newVisitorStatistic);
             _visitorStatisticService.SaveChanges();
             response = request.CreateResponse(HttpStatusCode.Created, category);
         }
         return response;
     }));
 }
Ejemplo n.º 3
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);
            // store the request in an accessible object
            var request = filterContext.HttpContext.Request;
            //generate a visitor statistic record.
            VisitorStatistic visitor = new VisitorStatistic()
            {
                UserName = (request.IsAuthenticated) ? filterContext.HttpContext.User.Identity.Name : "Annonymous",
                IPAddress = request.UserHostAddress ?? request.ServerVariables["HTTP_X_FORWARDED_FOR"],
                AlternateIPAddress = request.ServerVariables["REMOTE_ADDR"] ?? "Not Available",
                AreaAccessed = request.RawUrl,
                Timestamp = DateTime.UtcNow,
                Referer = request.ServerVariables["HTTP_REFERER"] ?? "internet",
                Browser = request.Browser.Browser
            };
            // stores the tracked info in the database
            VisitorStatisticsContext context = new VisitorStatisticsContext();
            context.VisitorStatisticRecords.Add(visitor);
            context.SaveChanges();

            //finished executing the action as normal
            base.OnActionExecuting(filterContext);
        }
 public void Update(VisitorStatistic visitorStatistic)
 {
     _visitorStatisticRepository.Update(visitorStatistic);
 }
 public void Add(VisitorStatistic visitorStatistic)
 {
     _visitorStatisticRepository.Add(visitorStatistic);
 }
Ejemplo n.º 6
0
 public static void UpdateVisitorStatistic(this VisitorStatistic visitorStatistic, VisitorStatisticViewModel visitorStatisticVM)
 {
     visitorStatistic.ID          = visitorStatisticVM.ID;
     visitorStatistic.VisitedDate = visitorStatisticVM.VisitedDate;
     visitorStatistic.IPAddress   = visitorStatisticVM.IPAddress;
 }
Ejemplo n.º 7
0
 public VisitorStatistic Add(VisitorStatistic visitorStatistic)
 {
     return(_visitorStatisticRepository.Add(visitorStatistic));
 }