Ejemplo n.º 1
0
        public JsonResult Get(int pageIndex,
                              int pageSize,
                              string pageOrder,
                              int productID,
                              string fromDate,
                              string toDate,
                              List <int> groups
                              )
        {
            DateTime?sDate = null,
                    eDate  = null;

            if (!String.IsNullOrWhiteSpace(fromDate))
            {
                sDate = Utilities.ToEnglishDate(fromDate).Date;
            }

            if (!String.IsNullOrWhiteSpace(toDate))
            {
                eDate = Utilities.ToEnglishDate(toDate).Date;
            }


            var list = ProductVisits.Get(pageIndex,
                                         pageSize,
                                         pageOrder,
                                         productID,
                                         sDate,
                                         eDate,
                                         groups
                                         );

            int total     = ProductVisits.Count(productID, sDate, eDate, groups);
            int totalPage = (int)Math.Ceiling((decimal)total / pageSize);

            if (pageSize > total)
            {
                pageSize = total;
            }

            if (list.Count < pageSize)
            {
                pageSize = list.Count;
            }

            JsonResult result = new JsonResult()
            {
                Data = new
                {
                    TotalPages = totalPage,
                    PageIndex  = pageIndex,
                    PageSize   = pageSize,
                    Rows       = list
                },
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            };

            return(result);
        }
Ejemplo n.º 2
0
 internal void IncProVisits(int ProductCode)
 {
     try
     {
         ProductVisits NewRecord = new ProductVisits();
         dataContext.ProductVisits.InsertOnSubmit(NewRecord);
         NewRecord.ProductCode = ProductCode;
         NewRecord.VisitDate   = DateTime.Now;
         dataContext.SubmitChanges();
     }
     catch
     {
     }
 }