Beispiel #1
0
 public ActionResult CreateNews(NewInfo info, FormCollection f)
 {
     if (Session["account"] is null)
     {
         return(RedirectToAction("Login", "Login"));
     }
     else
     {
         var              account   = Session["account"] as Account;
         var              listtopic = f["topicstring"].ToString().Split(new char[] { ',' });
         Newspaper        news      = new Newspaper();
         NewspaperService svn       = new NewspaperService();
         news.Active          = 0;
         news.PublicationDate = DateTime.Now;
         news.Journalist      = account.AccountName;
         news.Title           = info.Title;
         news.Image           = info.Image;
         news.Description     = info.Description;
         svn.AddNewspaper(news);
         var            result = svn.GetAll().Last();
         MappingService svm    = new MappingService();
         foreach (var item in listtopic)
         {
             svm.AddMapping(new Mapping {
                 NewsId = result.NewsId, TopicId = Int32.Parse(item)
             });
         }
         return(RedirectToAction("CreateNews"));
     }
 }
        // GET: Category
        public ActionResult Index()
        {
            TopicService      sertop  = new TopicService();
            List <eTopic>     lst     = new List <eTopic>();
            List <eNewspaper> listbao = new List <eNewspaper>();
            NewspaperService  serbao  = new NewspaperService();

            foreach (var item in serbao.GetAll())
            {
                listbao.Add(new eNewspaper()
                {
                    Title           = item.Title,
                    Active          = item.Active,
                    Description     = item.Description,
                    Image           = item.Image,
                    Journalist      = item.Journalist,
                    NewsId          = item.NewsId,
                    PublicationDate = (DateTime)item.PublicationDate
                });
            }
            ViewBag.ALlBao = listbao;
            foreach (var item in sertop.GetAll())
            {
                eTopic top = new eTopic()
                {
                    TopicId = item.TopicId, TopicName = item.TopicName
                };
                lst.Add(top);
            }
            return(View(lst));
        }
        public JsonResult getNew(int id)
        {
            TopicService     sertop  = new TopicService();
            MappingService   sermap  = new MappingService();
            NewspaperService sernews = new NewspaperService();

            if (id == 0)
            {
                return(Json(sernews.GetAll(), JsonRequestBehavior.AllowGet));
            }
            else
            {
                var query = (from tp in sertop.GetAll()
                             join
                             map in sermap.GetAll() on tp.TopicId equals map.TopicId
                             join
                             news in sernews.GetAll() on map.NewsId equals news.NewsId
                             where tp.TopicId == id
                             select new
                {
                    news.Image,
                    news.Title,
                    tp.TopicName,
                    news.NewsId
                }).ToList();
                ViewBag.getbaotheoIDTopic = query;

                return(Json(query, JsonRequestBehavior.AllowGet));
            }
        }
 public HomeApiController()
 {
     _newspaperService       = new NewspaperService(new DAL.LibraryContext("DbConnect"));
     _journalService         = new JournalService(new DAL.LibraryContext("DbConnect"));
     _bookService            = new BookService(new DAL.LibraryContext("DbConnect"));
     _publishingHouseService = new PublishingHouseService(new DAL.LibraryContext("DbConnect"));
 }
Beispiel #5
0
        public NewspaperServiceUnitTests()
        {
            newspaperService = new NewspaperService(Mock.Of <INewspaperRepository>(), Mock.Of <IEntityService>(), Mock.Of <IEntityRepository>()
                                                    , Mock.Of <IArticleRepository>(), Mock.Of <IUploadService>(), Mock.Of <IWarningService>(), Mock.Of <ITransactionsService>(), Mock.Of <IWalletService>(), Mock.Of <IConfigurationRepository>(),
                                                    Mock.Of <ICitizenService>());

            SingletonInit.Init();
        }
Beispiel #6
0
        public ActionResult UpdateNews(int newsid = 11)
        {
            if (Session["account"] is null)
            {
                return(RedirectToAction("Login", "Login"));
            }
            else
            {
                var account              = Session["account"] as Account;
                NewspaperService svn     = new NewspaperService();
                var            result    = svn.GetById(newsid);
                MappingService svm       = new MappingService();
                var            mapresult = svm.GetAll().Where(x => x.NewsId == result.NewsId).ToList();
                List <Topic>   lsttopic  = new List <Topic>();
                TopicService   svt       = new TopicService();
                foreach (var item in mapresult)
                {
                    lsttopic.Add(svt.GetById(item.TopicId));
                }
                string str = "";
                foreach (var item in lsttopic)
                {
                    str += item.TopicId + ",";
                }
                str = str.Substring(0, str.Length - 1);

                ViewBag.GetTopic = str;
                NewInfo newinfo = new NewInfo();
                newinfo.Title       = result.Title;
                newinfo.NewsId      = result.NewsId;
                newinfo.Image       = result.Image;
                newinfo.Journalist  = account.AccountName;
                newinfo.Description = result.Description;
                newinfo.Topic       = svt.GetAll().ToList();
                return(View(newinfo));
            }
        }
 public ActionResult UpdateNews(NewInfo info, FormCollection f)
 {
     if (Session["account"] is null)
     {
         return(RedirectToAction("Login", "Login"));
     }
     else
     {
         var              account   = Session["account"] as AccountLogin;
         var              listtopic = f["topicstring"].ToString().Split(new char[] { ',' });
         Newspaper        news      = new Newspaper();
         NewspaperService svn       = new NewspaperService();
         news.PublicationDate = DateTime.Now;
         news.Active          = 0;
         news.NewsId          = info.NewsId;
         news.Title           = info.Title;
         news.Image           = info.Image;
         news.Description     = info.Description;
         news.Journalist      = account.AccountName;
         svn.UpdateNewspaper(news);
         MappingService svm  = new MappingService();
         var            getm = svm.GetAll().Where(x => x.NewsId == news.NewsId);
         var            s    = getm.ToList().Count;
         foreach (var item in getm.ToList())
         {
             svm.DeleteMapping(item.MappingId);
         }
         foreach (var item in listtopic)
         {
             svm.AddMapping(new Mapping {
                 NewsId = info.NewsId, TopicId = Int32.Parse(item)
             });
         }
         return(RedirectToAction("UpdateNews"));
     }
 }
Beispiel #8
0
 public JournalistController()
 {
     _newsService    = new NewspaperService();
     _userService    = new UserService();
     _accountService = new AccountService();
 }
 public NewspaperController(NewspaperService serv)
 {
     _newspaperService = serv;
 }
 public NewspaperController()
 {
     _newspaperService = new NewspaperService(new DAL.LibraryContext("DbConnect"));
 }
Beispiel #11
0
 public NewspaperController(NewspaperService newspaperService)
 {
     _newspaperService = newspaperService;
 }
 public ApprovalController()
 {
     _newspaperService = new NewspaperService();
 }
Beispiel #13
0
 public NewspapersController(NewspaperService newspaperService, LibraryStorageUnitService libraryStorageUnitService)
 {
     _newspaperService          = newspaperService;
     _libraryStorageUnitService = libraryStorageUnitService;
 }