Ejemplo n.º 1
0
        public ActionResult NewDetail(New_t n)
        {
            n.UpdateIssueDateByTime();
            if (SessionData.Current.NewId.HasValue)
            {
                n.Id = SessionData.Current.NewId.Value;
            }
            if (ModelState.IsValid)
            {
                if (CurrentUserID.HasValue)
                {
                    _ins.AddOrUpdate(n, CommonData.Current.UserId.Value);
                }
                else
                {
                    throw new Exception("User must be loged in");
                }

                return(RedirectToAction("News"));
            }
            else
            {
                n.AlbumIds = SessionData.Current.AlbumIds;
                return(View(n));
            }
        }
Ejemplo n.º 2
0
        public int AddOrUpdate(New_t n, int userId)
        {
            New_t tmpnr = null;

            if (n.Id > 0)
            {
                tmpnr = _nr.GetById(n.Id);
            }

            if (tmpnr == null)
            {
                tmpnr = new New_t();
            }

            tmpnr.IssueDate = n.IssueDate;
            tmpnr.Text      = n.Text;
            tmpnr.Title     = n.Title;
            tmpnr.UserId    = userId;
            tmpnr.AlbumId   = n.AlbumId;
            tmpnr.Location  = n.Location;

            if (tmpnr.Id == 0)
            {
                tmpnr.CreatedDate = DateTime.Now;
                this._nr.Add(tmpnr);
            }
            this._nr.SaveAll();
            return(tmpnr.Id);
        }