Ejemplo n.º 1
0
        //前台Application内容
        public ActionResult DataApplicationDetail(int ID = 0)
        {
            DataApplicationViewModel viewmodel;

            if (ID != 0)
            {
                var item = dataapplicationService.LoadEntites(o => o.ID == ID).First();
                viewmodel = new DataApplicationViewModel
                {
                    ID = item.ID,
                    Data_Application_Name    = item.Data_Application_Name,
                    Data_Application_Content = item.Data_Application_Content,
                    CreateDateTime           = item.CreateDateTime,
                    UpdateDateTime           = item.UpdateDateTime,
                    Data_Image     = item.Data_Image,
                    DownloadCount  = item.DownloadCount,
                    PageViewCount  = item.PageViewCount,
                    Data_IsPublish = item.Data_IsPublish,
                };

                //增加访问量start
                data_application dinfo = new data_application
                {
                    ID = item.ID,
                    Data_Application_Name    = item.Data_Application_Name,
                    Data_Application_Content = item.Data_Application_Content,
                    CreateDateTime           = item.CreateDateTime,
                    UpdateDateTime           = item.UpdateDateTime,
                    Data_Image     = item.Data_Image,
                    DownloadCount  = item.DownloadCount,
                    PageViewCount  = item.PageViewCount + 1,
                    Data_IsPublish = item.Data_IsPublish,
                };
                if (dinfo.ID > 0)
                {
                    dataapplicationService.UpdateEntity(dinfo);
                }

                //增加访问量end
            }
            else
            {
                viewmodel = new DataApplicationViewModel();
            }
            ViewData.Model = viewmodel;
            return(View());
        }
Ejemplo n.º 2
0
 public JsonResult CreateDataApplition(DataApplicationViewModel item)
 {
     try
     {
         data_application dinfo = new data_application
         {
             ID = item.ID,
             Data_Application_Name    = item.Data_Application_Name,
             Data_Application_Content = item.Data_Application_Content,
             CreateDateTime           = DateTime.Now,
             UpdateDateTime           = DateTime.Now,
             Data_Image     = item.Data_Image,
             DownloadCount  = 0,
             PageViewCount  = 0,
             Data_IsPublish = item.Data_IsPublish,
         };
         if (dinfo.ID > 0)
         {
             dinfo.CreateDateTime = item.CreateDateTime;
             dinfo.UpdateDateTime = DateTime.Now;
             dataapplicationService.UpdateEntity(dinfo);
         }
         else
         {
             dinfo.UpdateDateTime = DateTime.Now;
             dinfo.CreateDateTime = DateTime.Now;
             dataapplicationService.AddEntity(dinfo);
         }
         var result = new { State = "Success" };
         return(Json(result, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         var result = new { State = "Exception", Message = ex.Message };
         return(Json(result, JsonRequestBehavior.AllowGet));
     }
 }