Exemplo n.º 1
0
        public bool Add(iPow.Infrastructure.Data.DataSys.Sys_SightComm enitty, iPow.Infrastructure.Data.DataSys.Sys_AdminUser operUser)
        {
            var res = false;

            if (enitty != null)
            {
                try
                {
                    sightCommRepository.Add(enitty);
                    sightCommRepository.Uow.Commit();
                    res = true;
                }
                catch (Exception ex)
                {
                }
            }
            return(res);
        }
Exemplo n.º 2
0
        public ActionResult AddSightComm(FormCollection f)
        {
            try
            {
                iPow.Infrastructure.Data.DataSys.Sys_SightComm comm = new Infrastructure.Data.DataSys.Sys_SightComm();
                comm.AddTime  = System.DateTime.Now;
                comm.UserName = f["txtUserName"].ToString();
                comm.UserID   = 0;
                //comm.CommID = Bll.Db.db.Sys_SightComm.Max(e => e.CommID) + 1;
                comm.Content = f["txtContent"].ToString();
                int fen = 0;
                if (f["score"] != null)
                {
                    int.TryParse(f["score"].ToString(), out fen);
                }
                comm.Fen = fen;
                comm.Ip  = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];;
                if (comm.Ip.CompareTo("::1") == 0)
                {
                    comm.Ip = "127.0.0.1";
                }
                comm.ParentID = 0;
                string sightId = f["txtSightId"].ToString();
                int    id      = 0;
                int.TryParse(sightId, out id);
                comm.SightID = id;
                string sightPy = f["txtSightPy"].ToString();
                sightCommRepository.Add(comm);


                //这个地方,只是给景区的一个评论字段加一,其实,可以不要这个字段的,
                //Sys_SightInfo sightInfo = sightInfoService.GetSightSingleById(comm.SightID);
                //if (sightInfo != null)
                //{
                //    sightInfo.CommCount += 1;
                //}

                sightCommRepository.Uow.Commit();
                int total = 0;
                var data  = sightInfoService.GetSightCommList(comm.SightID, 1, pageSizeForCommList, ref total);
                Webdiyer.WebControls.Mvc.PagedList <iPow.Domain.Dto.Sys_SightCommDto> model =
                    new Webdiyer.WebControls.Mvc.PagedList <iPow.Domain.Dto.Sys_SightCommDto>(data, 1, 5, total);
                ViewBag.parkid = comm.SightID;
                return(PartialView("CommList", model));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", "Home"));
            }
        }