Beispiel #1
0
        public ActionResult SaveEdit(ThemTinTucModel model)
        {
            #region update tin tuc

            DetailMenu dlcu = _detailMenuRepository.GetById(model.id_);
            dlcu.id_       = model.id_;
            dlcu.Name      = model.Name;
            dlcu.Img       = (model.Img).Replace("/files/", "");
            dlcu.Link      = model.Link;
            dlcu.id_       = model.id_;
            dlcu.Note      = model.Note;
            dlcu.sPosition = model.sPosition;
            dlcu.sDate     = DateTime.Now;
            dlcu.sDateOk   = DateTime.Now;
            //dlcu.Content =  ChangeImageSEO(model.Content, model.Name, ConvertFont(model.Name));
            dlcu.Content        = model.Content;
            dlcu.SEODescription = model.SEODescription;
            dlcu.SEOtitle       = model.SEOtitle;
            dlcu.CodeName       = ConvertFont(model.Name).Replace("-", " ");
            dlcu.IdSalePage     = model.IdSalePage;
            dlcu.NguoiTao       = User.Identity.Name;
            _detailMenuRepository.Update(dlcu);
            _unitOfWork.Commit();

            #endregion

            if (model.mySingleField != null)
            {
                #region danh sach tag
                string[] separators = { "," };
                var      taglist    = model.mySingleField.Split(separators, StringSplitOptions.RemoveEmptyEntries);
                //check null: nếu tồn tại thêm mới bình thường
                if (taglist.Any())
                {
                    foreach (var tag in taglist)
                    {
                        //check trung
                        int checktrung = _tagTinTucRepository.GetTagNamebyIdmenu(model.id_, tag.Trim());
                        if (checktrung == 0)
                        {
                            TagTinTuc _tag = new TagTinTuc()
                            {
                                NgayTao = DateTime.Now,
                                IdMenu  = dlcu.id_,
                                TenTag  = tag.Trim(),
                                Link    = ConvertFont(tag.Trim()),
                                Code    = RejectMarks(tag.Trim())
                            };
                            _tagTinTucRepository.Add(_tag);
                            _unitOfWork.Commit();
                        }
                    }
                }
                #endregion
            }

            return(RedirectToAction("Index"));
        }
        public ActionResult SaveEdit(ReviewModel model)
        {
            Review dlcu = _reviewRepository.GetById(model.id_);

            dlcu.id_     = model.id_;
            dlcu.TieuDe  = model.TieuDe;
            dlcu.HinhAnh = (model.HinhAnh).Replace("/files/", "");
            dlcu.Link    = model.Link;
            dlcu.id_     = model.id_;
            dlcu.Mota    = model.Mota;
            dlcu.Sapxep  = model.Sapxep;
            dlcu.Sdate   = DateTime.Now;
            //dlcu.ChiTiet = ChangeImageSEO(model.ChiTiet, model.TieuDe, ConvertFont(model.TieuDe));
            dlcu.ChiTiet        = model.ChiTiet;
            dlcu.SEODescription = model.SEODescription;
            dlcu.SEOtitle       = model.SEOtitle;
            dlcu.NguoiTao       = User.Identity.Name;
            _reviewRepository.Update(dlcu);
            _unitOfWork.Commit();
            if (model.mySingleField != null)
            {
                #region danh sach tag
                string[] separators = { "," };
                var      taglist    = model.mySingleField.Split(separators, StringSplitOptions.RemoveEmptyEntries);
                //check null: nếu tồn tại thêm mới bình thường
                if (taglist.Any())
                {
                    foreach (var tag in taglist)
                    {
                        //check trung
                        int checktrung = _tagTinTucRepository.GetTagNamebyIdmenu(model.id_, tag.Trim());
                        if (checktrung == 0)
                        {
                            TagTinTuc _tag = new TagTinTuc()
                            {
                                NgayTao = DateTime.Now,
                                IdMenu  = dlcu.id_,
                                TenTag  = tag.Trim(),
                                Link    = ConvertFont(tag.Trim()),
                                Code    = RejectMarks(tag.Trim())
                            };
                            _tagTinTucRepository.Add(_tag);
                            _unitOfWork.Commit();
                        }
                    }
                }
                #endregion
            }
            return(RedirectToAction("Index"));
        }