예제 #1
0
        private void LoadController()
        {
            // HospitalManagementController
            doctorStatisticsController    = new DoctorStatisticsController(doctorStatisticsService);
            inventoryStatisticsController = new InventoryStatisticsController(inventoryStatisticsService);
            roomStatisticsController      = new RoomStatisticsController(roomStatisticsService);
            hospitalController            = new HospitalController(hospitalService);
            medicineController            = new MedicineController(medicineService);
            roomController      = new RoomController(roomService);
            inventoryController = new InventoryController(inventoryService);

            // MedicalController
            appointmentController = new AppointmentController(appointmentService, appointmentRecommendationService);
            diseaseController     = new DiseaseController(diseaseService);

            // MiscController
            articleController        = new ArticleController(articleService);
            doctorFeedbackController = new DoctorFeedBackController(doctorFeedbackService);
            feedbackController       = new FeedbackController(feedbackService);
            locationController       = new LocationController(locationService);
            messageController        = new MessageController(messageService);
            notificationController   = new NotificationController(notificationService);

            // UsersController
            doctorController    = new DoctorController(doctorService, diagnosisService, therapyService, medicalRecordService);
            managerController   = new ManagerController(managerService);
            patientController   = new PatientController(patientService, medicalRecordService, therapyService, diagnosisService);
            secretaryController = new SecretaryController(secretaryService);
            userController      = new UserController(userService);
        }
예제 #2
0
        //[DnnAuthorize(AllowAnonymous = true)]
        public HttpResponseMessage GetArticle(int articleId)
        {
            try
            {
                var a = ArticleController.GetArticle(articleId);

                var newArt = new ArticleViewModel
                {
                    ArticleId            = a.ArticleId,
                    Body                 = WebUtility.HtmlDecode(a.Body),
                    CreatedByUser        = a.CreatedByUser,
                    CreatedByUserId      = a.CreatedByUserId,
                    CreatedOnDate        = a.CreatedOnDate,
                    Description          = WebUtility.HtmlDecode(a.Description),
                    LastModifiedByUser   = a.LastUpdatedByUser,
                    LastModifiedByUserId = a.LastModifiedByUserId,
                    LastModifiedOnDate   = a.LastModifiedOnDate,
                    ModuleId             = a.ModuleId,
                    Title                = a.Title,
                    url = DotNetNuke.Common.Globals.NavigateURL(a.TabID, "", "&aid=" + a.ArticleId)
                };

                return(Request.CreateResponse(HttpStatusCode.OK, newArt));
            }
            catch (Exception exc)
            {
                DnnLog.Error(exc);                                                             //todo: obsolete
                return(Request.CreateResponse(HttpStatusCode.BadRequest, "error in request")); //todo: probably should localize that?
            }
        }
예제 #3
0
        public static void ImportFromExcel(string path)
        {
            List <ArticleModel> ArticlesFromExcel = ExcelEditor.ArticlesFromExcel(path);

            CheckAndCreateReferences(ArticlesFromExcel);
            SQLiteConnection con   = new SQLiteConnection(InventoryDBSqliteConnection.LoadConnectionString());
            string           query = "INSERT INTO Articles (ArticleID, Description, ID_Category, Pricing, Quantity, ID_Project, SupplierPartNumber, ManufacturerPartNumber, ID_Manufacturer, ID_Supplier, ID_Status, Created, LastUpdate, ID_Location) VALUES (@ArticleID, @Description, @ID_Category, @Pricing, @Quantity, @ID_Project, @SupplierPartNumber, @ManufacturerPartNumber, @ID_Manufacturer, @ID_Supplier, @ID_Status, @Created, @LastUpdate, @ID_Location)";
            SQLiteCommand    cmd   = new SQLiteCommand(query, con);

            con.Open();
            foreach (ArticleModel article in ArticlesFromExcel)
            {
                if (ArticleController.checkSupplierAndManufacturerPartNumber(article.ManufacturerPartNumber, article.SupplierPartNumber).Count == 0)
                {
                    cmd.Parameters.AddWithValue("@ArticleID", article.ArticleID);
                    cmd.Parameters.AddWithValue("@Description", article.Description);
                    cmd.Parameters.AddWithValue("@ID_Category", getThreeDigits(article.ArticleID.ToString()));
                    cmd.Parameters.AddWithValue("@Pricing", article.Pricing);
                    cmd.Parameters.AddWithValue("@Quantity", article.Quantity);
                    cmd.Parameters.AddWithValue("@ID_Project", article.ID_Project);
                    cmd.Parameters.AddWithValue("@SupplierPartNumber", article.SupplierPartNumber);
                    cmd.Parameters.AddWithValue("@ManufacturerPartNumber", article.ManufacturerPartNumber);
                    cmd.Parameters.AddWithValue("@ID_Manufacturer", ManufacturerController.getManufacturerID(article.Manufacturer));
                    cmd.Parameters.AddWithValue("@ID_Supplier", SupplierController.getSupplierID(article.Supplier));
                    cmd.Parameters.AddWithValue("@ID_Status", StatusController.getStatusID(article.Status));
                    cmd.Parameters.AddWithValue("@Created", article.Created);
                    cmd.Parameters.AddWithValue("@LastUpdate", DateTime.Now.ToString("dd/MM/yyyy"));
                    cmd.Parameters.AddWithValue("@ID_Location", LocationController.getLocationID(article.Location));
                    cmd.ExecuteNonQuery();
                }
            }
            con.Close();
            MessageBox.Show("Import done succesfully, Please restart the Application");
            //MessageBox.Show(article.ArticleID + ": " + article.Description + " was added successfully");
        }
예제 #4
0
 public void Init()
 {
     articleServiceMock = new Mock <IArticleService>();
     mapperMock         = new Mock <IMapper>();
     userIdentityMock   = new Mock <IUserIdentity>();
     articleController  = new ArticleController(articleServiceMock.Object, mapperMock.Object, userIdentityMock.Object);
 }
예제 #5
0
        public void GetByIssueId()
        {
            using (var ctx = new JournalDbContext(DbOptions))
            {
                //Arrange
                var issueController = new IssueController(new IssueService(ctx), MapperConfig.Configure());
                var controller      = new ArticleController(new ArticleService(ctx), MapperConfig.Configure());

                //Act
                var issueResult         = issueController.Get();
                var issueOkObjectResult = issueResult as OkObjectResult;
                var issueModel          = issueOkObjectResult.Value as IEnumerable <IssueModel>;

                var result = controller.GetByIssue(issueModel.Single().AllTime);

                //Assert
                var okObjectResult = result as OkObjectResult;
                Assert.NotNull(okObjectResult);

                var model = okObjectResult.Value as IEnumerable <ArticleModel>;
                Assert.NotNull(model);

                Assert.Equal(2, model.Count());
            }
        }
        public Blogic()
        {
            var app = Application.Current as App;

            articleController = app.articleController;

            InitializeComponent();
            if (ArticlesList != null)
            {
                ArticlesList.ItemsSource = new List <ArticleShow>();
                articlesToShow           = new List <ArticleShow>();
                foreach (Article art in articleController.GetAllArticles())
                {
                    articlesToShow.Add(new ArticleShow()
                    {
                        article = new ModelHCI.ArticleHCI()
                        {
                            article = art, content = art.PostContent.Content, title = art.PostContent.ContentTitle, articlePic = new BitmapImage(new Uri(art.Image, UriKind.Relative))
                        },
                        buttonContent = "Prikaži ceo",
                        info          = new ButtonTagInfo()
                        {
                            article = new ModelHCI.ArticleHCI()
                            {
                                article = art, content = art.PostContent.Content, title = art.PostContent.ContentTitle, articlePic = new BitmapImage(new Uri(art.Image, UriKind.RelativeOrAbsolute))
                            }
                        }
                    });
                    pageCount = articlesToShow.Count;
                    ArticlesList.ItemsSource = articlesToShow;
                }
                //Pagination();
            }
        }
예제 #7
0
        public void Add()
        {
            //Arrange
            using (var ctx = new JournalDbContext(DbOptions))
            {
                //Arrange
                var issueController = new IssueController(new IssueService(ctx), MapperConfig.Configure());
                var controller      = new ArticleController(new ArticleService(ctx), MapperConfig.Configure());

                //Act
                var issueResult         = issueController.Get();
                var issueOkObjectResult = issueResult as OkObjectResult;
                var issueModel          = issueOkObjectResult.Value as IEnumerable <IssueModel>;

                //Act
                controller.Post(new ArticleModel()
                {
                    IssueId = issueModel.Single().Id,
                    Title   = "Receptek"
                });
            }

            //Assert
            using (var ctx = new JournalDbContext(DbOptions))
            {
                var iss = ctx.Articles.ToList();
                Assert.Equal(3, ctx.Articles.Count());
            }
        }
예제 #8
0
        public void Put()
        {
            int Id = 0;

            //Arrange
            using (var ctx = new JournalDbContext(DbOptions))
            {
                var controller = new ArticleController(new ArticleService(ctx), MapperConfig.Configure());

                //Act
                var result         = controller.Get();
                var okObjectResult = result as OkObjectResult;
                var model          = okObjectResult.Value as IEnumerable <ArticleModel>;

                Id = model.First().Id;

                controller.Put(model.First().Id, new ArticleModel
                {
                    Id    = model.First().Id,
                    Title = "Sudoku"
                });
            }

            //Assert
            using (var ctx = new JournalDbContext(DbOptions))
            {
                Assert.Equal(2, ctx.Articles.Count());
                Assert.Equal("Sudoku", ctx.Articles.Where(a => a.Id == Id).Single().Title);
            }
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Page_Load runs when the control is loaded
        /// </summary>
        /// -----------------------------------------------------------------------------
        private void Page_Load(object sender, EventArgs e)
        {
            try
            {
                //Implement your edit logic for your module
                if (!Page.IsPostBack)
                {
                    var article = new Article();
                    tsTerms.Terms = article.Terms;
                    article       = ArticleController.GetArticle(ArticleId);

                    tsTerms.PortalId = PortalId;

                    urlImage.UrlType    = "F";
                    urlImage.FileFilter = "jpg,jpeg,jpe,gif,bmp,png";

                    if (article != null)
                    {
                        txtTitle.Text       = article.Title;
                        txtDescription.Text = article.Description;
                        txtBody.Text        = article.Body;
                        tsTerms.Terms       = article.Terms;
                        urlImage.Url        = article.LargeImg;
                    }

                    tsTerms.DataBind();
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
예제 #10
0
        private void PopulateRelatedNews(string code, string alias)
        {
            string         strHTML = string.Empty, list = string.Empty, strCreateDate = string.Empty;
            int            totalItemCount = 10;
            List <Article> lst            = ArticleController.GetActiveListByFixedNumCode(code, totalItemCount);
            DataTable      dt             = CommonLibrary.Common.Utilities.CollectionsUtil.ConvertTo(lst);

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (!string.IsNullOrEmpty(dt.Rows[i]["DateCreated"].ToString()))
                    {
                        DateTime _strCreateDate = Convert.ToDateTime(dt.Rows[i]["DateCreated"].ToString());
                        strCreateDate = "<span class='date'>(" + _strCreateDate.ToString("dd/MM/yy") + ")</span>";
                    }

                    if (dt.Rows[i]["Alias"].ToString() != alias)
                    {
                        list += "<li><a  target='_self' title=\"" + dt.Rows[i]["Headline"].ToString() + "\" href=\"/tin-chi-tiet/" + dt.Rows[i]["Alias"].ToString() + "/" + code + "\"><span>"
                                + dt.Rows[i]["Headline"].ToString() + "</span>" + strCreateDate + "</a></li>";
                    }
                }
            }

            ltrRelationNews.Text = "<div class=\"detail-related\">"
                                   + "<ul>"
                                   + list
                                   + "</ul>"
                                   + "</div>";
        }
예제 #11
0
        public async Task NetSearchTest()
        {
            await DbContext.Categories.AddAsync(new Category { Id = ArticleCategory.Net, Color = "", Label = "", Value = "" });

            await DbContext.Categories.AddAsync(new Category { Id = ArticleCategory.Database, Color = "", Label = "", Value = "" });

            await DbContext.Articles.AddAsync(new Article { Id = 1, Title = "test1", CategoryId = ArticleCategory.Net, Status = BaseStatus.Disabled });

            await DbContext.Articles.AddAsync(new Article { Id = 2, Title = "test2", CategoryId = ArticleCategory.Net, Status = BaseStatus.Enabled });

            await DbContext.Articles.AddAsync(new Article { Id = 3, Title = "test3", CategoryId = ArticleCategory.Database, Status = BaseStatus.Enabled });

            await DbContext.SaveChangesAsync();

            var articleService = new ArticleService(DbContext, Mapper);
            var identity       = new ClaimsIdentity(new List <Claim>());
            var controller     = new ArticleController(articleService, null)
            {
                ControllerContext = new ControllerContext
                {
                    HttpContext = new DefaultHttpContext
                    {
                        User = new ClaimsPrincipal(identity)
                    }
                }
            };

            var result = await controller.Search("net:est");

            var viewReuslt = result as ViewResult;
            var model      = viewReuslt.Model as Pagination <ArticleDto>;

            Assert.AreEqual(1, model.Data.Count);
            Assert.AreEqual(2, model.Data[0].Id);
        }
예제 #12
0
        public async Task EmptySearchTest()
        {
            await DbContext.Categories.AddAsync(new Category { Id = ArticleCategory.Essays, Color = "", Label = "", Value = "" });

            await DbContext.Categories.AddAsync(new Category { Id = ArticleCategory.Net, Color = "", Label = "", Value = "" });

            await DbContext.Articles.AddAsync(new Article { Id = 1, Title = "test1", CategoryId = ArticleCategory.Essays, Status = BaseStatus.Disabled });

            await DbContext.Articles.AddAsync(new Article { Id = 2, Title = "test2", CategoryId = ArticleCategory.Essays, Status = BaseStatus.Enabled });

            await DbContext.Articles.AddAsync(new Article { Id = 3, Title = "test3", CategoryId = ArticleCategory.Net, Status = BaseStatus.Enabled });

            await DbContext.SaveChangesAsync();

            var articleService = new ArticleService(DbContext, Mapper);
            var controller     = new ArticleController(articleService, null);

            var result = await controller.Search(" ");

            var viewResult = result as ViewResult;
            var model      = viewResult.Model as List <ArticleDto>;

            Assert.AreEqual(viewResult.ViewName, "EmptySearch");
            Assert.AreEqual(2, model.Count);
        }
예제 #13
0
        public async Task ReadTest()
        {
            await DbContext.Categories.AddAsync(new Category { Id = ArticleCategory.Read, Color = "", Label = "", Value = "" });

            await DbContext.Categories.AddAsync(new Category { Id = ArticleCategory.Essays, Color = "", Label = "", Value = "" });

            await DbContext.Articles.AddAsync(new Article { Id = 1, Title = "test1", CategoryId = ArticleCategory.Read, Status = BaseStatus.Disabled });

            await DbContext.Articles.AddAsync(new Article { Id = 2, Title = "test2", CategoryId = ArticleCategory.Read, Status = BaseStatus.Enabled });

            await DbContext.Articles.AddAsync(new Article { Id = 3, Title = "test3", CategoryId = ArticleCategory.Essays, Status = BaseStatus.Enabled });

            await DbContext.SaveChangesAsync();

            var articleService = new ArticleService(DbContext, Mapper);
            var controller     = new ArticleController(articleService, null);

            var result = await controller.Read();

            var viewReuslt = result as ViewResult;
            var model      = viewReuslt.Model as Pagination <ArticleDto>;

            Assert.AreEqual(1, model.Data.Count);
            Assert.AreEqual(2, model.Data[0].Id);
        }
예제 #14
0
        protected void NewPopulateData()
        {
            string            code        = "NEWS";
            int               record      = 4;
            string            strHTML     = string.Empty;
            string            path_image  = "/user_files/images/article_images/front_images/";
            ArticleController article_obj = new ArticleController();
            DataTable         dt          = article_obj.GetListByNumCode(code, record);

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    strHTML += "<ul class=\"typicalevents\">"
                               + "<li>"
                               + " <a title=\"" + dt.Rows[i]["Headline"].ToString() + "\" href=\"#\">"
                               + " <img class=\"newsphoto_small\" width=\"80\" height=\"57\" alt=\"" + dt.Rows[i]["Alias"].ToString() + "\" src='" + path_image + dt.Rows[i]["FrontImage"].ToString() + "' />"
                               + "<h4>"
                               + dt.Rows[i]["TiTle"].ToString()
                               + "</h4>"
                               + " </a>"
                               + "</li>"
                               + "</ul>";
                }
                divContent.InnerHtml = strHTML;
            }
        }
예제 #15
0
        public void ReturnDefaultView_WithListOfModels()
        {
            // Arrange
            var articleServiceMock = new Mock <IArticleServices>();

            List <Article> articles = new List <Article>()
            {
                new Article()
                {
                    Id = 1
                }
            };

            var articlesSetMock = new Mock <DbSet <Article> >().SetupData(articles);

            articleServiceMock.Setup(m => m.ListAllArticles()).Returns(articlesSetMock.Object);

            //var model = articles.Select(a => new ArticleViewModel() { Id = 1 });
            var controller = new ArticleController(articleServiceMock.Object);

            // Act & Assert
            controller
            .WithCallTo(c => c.AllArticles())
            .ShouldRenderDefaultView()
            .WithModel <IEnumerable <ArticleViewModel> >(m => m.First(a => a.Id == 1));
        }
예제 #16
0
 public ArticleControllerTests()
 {
     _mapper      = A.Fake <IMapper>();
     _mediator    = A.Fake <IMediator>();
     _fileManager = A.Fake <IFileManager>();
     _sut         = new ArticleController(_fileManager, _mapper, _mediator);
 }
        public ArticleControllerTest() : base()
        {
            _articleController = ServiceProvider.GetService <ArticleController>();;

            _mapper  = ServiceProvider.GetService <IMapper>();
            _freeSql = ServiceProvider.GetService <IFreeSql>();
        }
예제 #18
0
        private void LoadNewsHeaderSlide()
        {
            string         strHTML = string.Empty, result = string.Empty, link = string.Empty, Source = string.Empty;
            string         code            = "TT_SK";
            string         lang            = "vi-VN";
            int            totalItemCount  = 3;
            Uri            requestUri      = Context.Request.Url;
            string         baseUrl         = requestUri.Scheme + Uri.SchemeDelimiter + requestUri.Host + (requestUri.IsDefaultPort ? "" : ":" + requestUri.Port);
            string         main_image_path = "/user_files/images/article_images/main_images/";
            string         file_path       = baseUrl + main_image_path;
            List <Article> lst             = ArticleController.GetActiveListByFixedNumCode(code, lang, totalItemCount);

            foreach (var item in lst)
            {
                if (string.IsNullOrEmpty(item.Source))
                {
                    Source = Request.Url.Host;
                }
                else
                {
                    Source = item.Source;
                }

                result += "<li class=\"news-item\"><a class=\"news-item-link\" title=\"" + item.Title + "\" href=\"/tin-chi-tiet/" + item.Alias + "/" + code + "\">"
                          + item.Headline
                          + "<span class='author'>Nguồn:" + Source + "</span>"
                          + "</a></li>";
            }
            strHTML = "<ul id=\"news_ticker\" class=\"ticker\">" + result + "</ul>";
            newsticker_scroller.InnerHtml = strHTML;
        }
예제 #19
0
        public void CallGetArticleByIdOnce()
        {
            // Arrange
            var mockedMappingService = new Mock <IMappingService>();
            var mockedArticleService = new Mock <IArticleService>();
            var articleId            = Guid.NewGuid();

            Article article = new Article()
            {
                Title     = "title",
                Id        = articleId,
                Subheader = "subheader",
                Content   = "conteeent"
            };

            ArticleByIdViewModel viewModel = new ArticleByIdViewModel()
            {
                Title     = "title",
                Id        = articleId.ToString(),
                Subheader = "subheader",
                Content   = "conteeent"
            };

            mockedArticleService.Setup(x => x.GetArticleById(articleId.ToString())).Returns(article);
            mockedMappingService.Setup(x => x.Map <Article, ArticleByIdViewModel>(It.IsAny <Article>())).Returns(viewModel);

            var controller = new ArticleController(mockedMappingService.Object, mockedArticleService.Object);

            // Act
            controller.ById(viewModel.Id);

            // Assert
            mockedArticleService.Verify(x => x.GetArticleById(It.IsAny <string>()), Times.Once);
        }
예제 #20
0
        public async Task DisabledListTest()
        {
            var mockSvc = new Mock <IArticleService>();

            mockSvc
            .Setup(m => m.GetDisabledArticlesDtoAsync())
            .Returns(Task.FromResult(new List <ArticleDto>
            {
                new ArticleDto {
                    Id = 1, Title = "ArticleDto 1"
                },
                new ArticleDto {
                    Id = 2, Title = "ArticleDto 2"
                }
            }));

            var controller = new ArticleController(mockSvc.Object);
            var list       = await controller.GetDisabledList();

            Assert.AreEqual(2, list.Count);

            Assert.AreEqual(1, list[0].Id);
            Assert.AreEqual("ArticleDto 1", list[0].Title);

            Assert.AreEqual(2, list[1].Id);
            Assert.AreEqual("ArticleDto 2", list[1].Title);
        }
예제 #21
0
        /// <summary>
        /// Modify the selected article and save it.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_SubmitModifyArticle_Click(object sender, EventArgs e)
        {
            Reference   = textBox_RefArticle.Text;
            Description = textBox_Description.Text;
            Price       = textBox_PriceHT.Text;
            Quantity    = textBox_Quantity.Text;

            Sub_Familly_Index = comboBox_SubFamily.SelectedIndex;
            Mark_Index        = comboBox_Brand.SelectedIndex;


            float Price_Float  = float.Parse(Price);
            int   Quantity_Int = int.Parse(Quantity);

            SubFamillyController Sub_Familly_Controller = new SubFamillyController();
            List <SubFamilly>    List_Sub_Familly       = Sub_Familly_Controller.GetAllSubFamilly();
            SubFamilly           Sub_Familly            = List_Sub_Familly[Sub_Familly_Index];

            MarkController Mark_Controller = new MarkController();
            List <Mark>    List_Mark       = Mark_Controller.GetAllMark();
            Mark           Mark            = List_Mark[Mark_Index];

            ArticleController Article_Controller = new ArticleController();
            Article           Article            = Article_Controller.GetArticleByRef(Reference);

            Article_Controller.UpdateArticle(Reference, Description, Sub_Familly.RefSousFamille1, Mark.RefMarque1, Price_Float, Quantity_Int);
            MessageBox.Show("Article modified successfully ;)", "Article modified", MessageBoxButtons.OK, MessageBoxIcon.Information);

            this.DialogResult = DialogResult.OK;
            this.Dispose();
            //this.Close();
        }
예제 #22
0
        public async void IndexGet_Page_DoesntHave_Comments()
        {
            // Arrange
            var articleAdapterMock = new Mock <IArticleAdapter>();

            articleAdapterMock
            .Setup(aa => aa.GetArticleById(1))
            .Returns(Task.FromResult(new Models.Article {
                Id = 1, Text = "Test", CommentsCount = 2
            }));

            var commentAdapterMock = new Mock <ICommentAdapter>();

            commentAdapterMock
            .Setup(ca => ca.GetCommentsByPage(1, 3, 10))
            .Throws(new AdapterException(StatusCodes.Status404NotFound, "На данной странице нет комментариев"));

            var controller = new ArticleController(articleAdapterMock.Object, commentAdapterMock.Object, null);

            // Act
            var actual = await controller.Index(1, 3);

            // Assert
            var view  = Assert.IsType <ViewResult>(actual);
            var model = Assert.IsType <ArticleViewModel>(view.Model);

            Assert.Equal("На данной странице нет комментариев", model.Error.Text);
        }
예제 #23
0
        public string LoadSupportOnline()
        {
            string result = null;

            try
            {
                ArticleController article_obj   = new ArticleController();
                DataTable         dt            = article_obj.GetDetailByID(1);
                string            Hotline       = dt.Rows[0]["Hotline"].ToString();
                string            SupportOnline = dt.Rows[0]["SupportOnline"].ToString();

                result = "<div id=\"service-online\">"
                         + "<h4>Dịch vụ khách hàng trực tuyến</h4>"
                         + "<div class=\"hotline\">"
                         + Hotline
                         + "</div>"
                         + "<div class='content-details'>"
                         + "<div style=\"text-align:center\">"
                         + SupportOnline
                         + "</div>"
                         + "</div>";
            }
            catch (IndexOutOfRangeException ex) { ex.ToString(); }
            return(result);
        }
예제 #24
0
        public ActionResult BlockLatestAticles(int categoryid = 3, int groupid = -2, int page = 1)
        {
            _pageSize = 12;
            var data = new ArticleController().BlockNewsByGroup(categoryid, page, _pageSize, groupid, _isClearCache);

            return(PartialView(data));
        }
예제 #25
0
        public async void IndexGet_Success()
        {
            // Arrange
            var articleAdapterMock = new Mock <IArticleAdapter>();

            articleAdapterMock
            .Setup(aa => aa.GetArticleById(1))
            .Returns(Task.FromResult(new Models.Article {
                Id = 1, Text = "Test", CommentsCount = 0
            }));

            var commentAdapterMock = new Mock <ICommentAdapter>();

            commentAdapterMock
            .Setup(ca => ca.GetCommentsByPage(1, 1, 10))
            .Returns(Task.FromResult(new FilteredModels <CommentViewModel>
            {
                Items = new List <CommentViewModel>()
            }));

            var controller = new ArticleController(articleAdapterMock.Object, commentAdapterMock.Object, null);

            // Act
            var actual = await controller.Index(1, 1);

            // Assert
            var view  = Assert.IsType <ViewResult>(actual);
            var model = Assert.IsType <ArticleViewModel>(view.Model);

            Assert.Null(model.Error);
            Assert.Equal(1, model.Article.Id);
            Assert.Empty(model.Comments.Items);
        }
예제 #26
0
        public async void IndexPost_User_NotFound()
        {
            // Arrange
            var articleAdapterMock = new Mock <IArticleAdapter>();

            articleAdapterMock
            .Setup(aa => aa.GetArticleById(1))
            .Returns(Task.FromResult(new Models.Article {
                Id = 1, Text = "Test", CommentsCount = 0
            }));

            var userAdapterMock = new Mock <IUserAdapter>();

            userAdapterMock
            .Setup(ca => ca.GetById(1))
            .Throws(new AdapterException(StatusCodes.Status404NotFound, "Данный пользователь не найден"));

            var controller = new ArticleController(articleAdapterMock.Object, null, userAdapterMock.Object);

            // Act
            var actual = await controller.Index("Test", 1, 1, null);

            // Assert
            var view  = Assert.IsType <ViewResult>(actual);
            var model = Assert.IsType <ArticleViewModel>(view.Model);

            Assert.Equal("Данный пользователь не найден", model.Error.Text);
        }
예제 #27
0
        /// <summary>
        /// This is used to update the content in the ContentItems table. Should be called when an Article is updated.
        /// </summary>
        public void UpdateContentItem(Article objArticle, int tabId)
        {
            var origArticle = ArticleController.GetArticle(objArticle.ArticleId);
            var objContent  = Util.GetContentController().GetContentItem(objArticle.ContentItemId);

            if (objContent == null)
            {
                return;
            }
            objContent.Content = objArticle.Title + " " + HttpUtility.HtmlDecode(objArticle.Description);
            objContent.TabID   = tabId;

            objContent.Metadata.Add("SimpleArticleThumbImg", objArticle.ThumbImg);
            objContent.Metadata.Add("SimpleArticleLargeImg", objArticle.LargeImg);

            //TODO: removed 7/19/2012 because metadata is useless
            //delete only works if there is only one description in metadata
            //Util.GetContentController().DeleteMetaData(objContent, "Description", origArticle.Metadata["Description"]);
            //Util.GetContentController().AddMetaData(objContent, "Description", objArticle.Description);

            Util.GetContentController().UpdateContentItem(objContent);

            // Update Terms
            var cntTerm = new Terms();

            cntTerm.ManageArticleTerms(objArticle, objContent);
        }
예제 #28
0
        public void Article_Invalid_Id_Should_Redirect_To_Index()
        {
            ArticleController controller = new ArticleController();

             RedirectToRouteResult result;  // = (ViewResult)controller.ShowArticle(-1, "", 0, 0);
             //Assert.AreEqual("Index", result.RouteValues("action"));
        }
예제 #29
0
        private int AddData()
        {
            string userid        = Session["UserId"].ToString();
            int    portalid      = Convert.ToInt32(ddlPortalList.SelectedValue);
            string culturecode   = ddlCultureList.SelectedValue;
            string code          = ddlTreeNode_Category.SelectedValue;
            string title         = txtTitle.Text;
            string headline      = txtHeadline.Text;
            string abstract_info = txtAbstract.Text;
            string contents      = FCKeditorContent.Value;
            string source        = txtSource.Text;
            string status        = rdlStatus.SelectedValue;
            string navigateurl   = txtNavigateUrl.Text;
            /*** UPLOAD ****************************************************************************************************************************************/
            string         front_img = "", main_img = "";
            HttpPostedFile myfile = FileInput.PostedFile;

            if (myfile.FileName != string.Empty)
            {
                string front_img_path = Server.MapPath("~/" + System.Configuration.ConfigurationManager.AppSettings["upload_image_dir"] + "/article_images/front_images");
                string main_img_path  = Server.MapPath("~/" + System.Configuration.ConfigurationManager.AppSettings["upload_image_dir"] + "/article_images/main_images");

                FileHandleClass file_handle_obj = new FileHandleClass();
                string[]        FileImg         = new String[2];
                FileImg   = file_handle_obj.uploadFrontMainInputFile(myfile, front_img_path, main_img_path, 120, 120);
                main_img  = FileImg[0].ToString();
                front_img = FileImg[1].ToString();
            }
            /*************************************************************************************************************************************************/
            ArticleController article_obj = new ArticleController();
            int i = article_obj.Insert(userid, portalid, culturecode, code, title, headline, abstract_info, front_img, main_img, contents, source, navigateurl, status);

            return(i);
        }
예제 #30
0
        protected void ApsPopulateData()
        {
            string code = "ADS_NEWS";
            int    record = 4;
            string strHTML = string.Empty, Alias = string.Empty, Headline = string.Empty, Source = string.Empty,
                   Abstract = string.Empty, FilePath = string.Empty, Link = string.Empty;

            ArticleController article_obj = new ArticleController();
            DataTable         dt          = article_obj.GetListByNumCode(code, record);

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    Abstract = dt.Rows[i]["Abstract"].ToString();
                    Alias    = dt.Rows[i]["Alias"].ToString();
                    Headline = dt.Rows[i]["Headline"].ToString();
                    Source   = dt.Rows[i]["Source"].ToString();

                    if (!string.IsNullOrEmpty(dt.Rows[i]["FrontImage"].ToString()))
                    {
                        FilePath = "/user_files/images/article_images/front_images/" + dt.Rows[i]["FrontImage"].ToString();
                    }
                    else
                    {
                        FilePath = "/images/no_image.jpg";
                    }


                    if (string.IsNullOrEmpty(dt.Rows[i]["NavigateUrl"].ToString()))
                    {
                        Link = "/tin-chi-tiet/" + Alias + "/" + code;
                    }
                    else
                    {
                        Link = dt.Rows[i]["NavigateUrl"].ToString();
                    }

                    if (string.IsNullOrEmpty(dt.Rows[i]["Source"].ToString()))
                    {
                        Source = Request.Url.Host;
                    }
                    else
                    {
                        Source = dt.Rows[i]["Source"].ToString();
                    }

                    strHTML += "<div class='divAdvItems'>"
                               + "<div class='divTitle'><a target='_self' href='" + Link + "' >" + Headline + "</a></div>"
                               + "<div class='itemmc'><a target='_self' href='" + Link + "' >Nguồn: " + Source + "</a></div>"
                               + "<div class='divImage'>"
                               + "<a target='_self' href='" + Link + "'><img vspace='0' hspace='0' border='0' align='left' alt='" + Alias + "' src='" + FilePath + "' /></a>"
                               + "<div class='price'><a target='_self' href='" + Link + "' >" + Abstract + "</a></div>"
                               + "</div>"
                               + "</div>"
                               + "<div class='divBorder'><span></span></div>";
                }
                divAds.InnerHtml = strHTML;
            }
        }
예제 #31
0
        public void ReturnDefaultView_WithCorrectViewModel()
        {
            //Arrange
            var    articleServiceMock = new Mock <IArticleServices>();
            int    articleId          = 1;
            string author             = "author";
            string title   = "title";
            string content = "content";
            var    article = new Article()
            {
                Id      = articleId,
                Author  = author,
                Title   = title,
                Content = content
            };

            articleServiceMock.Setup(m => m.FindArticle(articleId)).Returns(article);
            var controller = new ArticleController(articleServiceMock.Object);

            // Act & Assert
            controller
            .WithCallTo(c => c.ArticleDetails(articleId))
            .ShouldRenderDefaultView()
            .WithModel <ArticleViewModel>(m => m.Id == articleId);
        }
        public void SetUp()
        {
            _mockRepository = new MockRepository();
            _articleService = _mockRepository.DynamicMock<IArticleService>();

            _articleController = new ArticleController(_articleService);
            Mapper.CreateMap<Article, ArticleModel>();
            Mapper.CreateMap<ArticleModel, Article>();
        }
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                this.FillModuleList();
            }

            ArticlesList.Items.Clear();

            ArticleController articleController = new ArticleController();

            int newsArticlesModuleId = 0;
            int newsArcticlesTabId = 0;

            if (ModuleListDropDown.Items.Count > 0)
            {
                string[] values = ModuleListDropDown.SelectedValue.Split(Convert.ToChar("-"));

                if (values.Length == 2)
                {
                    newsArcticlesTabId = Convert.ToInt32(values[0]);
                    newsArticlesModuleId = Convert.ToInt32(values[1]);
                }
            }

            var articleList = articleController.GetArticleList(newsArticlesModuleId, true);

            foreach (var article in articleList)
            {
                var articleUrl = Globals.NavigateURL(
                     newsArcticlesTabId,
                    string.Empty,
                    string.Format("articletype=ArticleView&articleId={0}", article.ArticleID));

                ArticlesList.Items.Add(new ListItem { Text = article.Title, Value = articleUrl });
            }
        }
예제 #34
0
        public void CanPaginate()
        {
            // Организация (arrange)
            var mock = new Mock<IArticleRepository>();
            mock.Setup(m => m.Articles).Returns(new List<Article>
            {
                new Article("375B7984-4C3F-446C-A8A3-E86077AADD3B") { Name = "Хуйня1", Description = "Статья про хуй", Content = "Жил был хуй", Tags = new List<Tag>(2)
                {
                    new Tag{ TagId = Guid.NewGuid(), Name = "хуй" },
                    new Tag{ TagId = Guid.NewGuid(), Name = "член" },
                    new Tag{ TagId = Guid.NewGuid(), Name = "писька" },
                    new Tag{ TagId = Guid.NewGuid(), Name = "пеннис" }
                }},
                new Article("375B7984-4C3F-446C-A8A3-E86077AADD3B") { Name = "Хуйня2", Description = "Статья про хуй", Content = "Жил был хуй", Tags = new List<Tag>(2)
                {
                    new Tag{ TagId = Guid.NewGuid(), Name = "хуй" },
                }},
                new Article("375B7984-4C3F-446C-A8A3-E86077AADD3B") { Name = "Хуйня3", Description = "Статья про хуй", Content = "Жил был хуй", Tags = new List<Tag>(2)
                {
                    new Tag{ TagId = Guid.NewGuid(), Name = "член" },
                }},
                new Article("375B7984-4C3F-446C-A8A3-E86077AADD3B") { Name = "Хуйня4", Description = "Статья про хуй", Content = "Жил был хуй", Tags = new List<Tag>(2)
                {
                    new Tag{ TagId = Guid.NewGuid(), Name = "писька" },
                }},
                new Article("375B7984-4C3F-446C-A8A3-E86077AADD3B") { Name = "Хуйня5", Description = "Статья про хуй", Content = "Жил был хуй", Tags = new List<Tag>(2)
                {
                    new Tag{ TagId = Guid.NewGuid(), Name = "пеннис" },
                }},
            });
            var controller = new ArticleController(mock.Object) {_pageSize = 3};

            // Действие (act)
            var result = (ArticleListViewModel)controller.List(string.Empty, 2).Model;

            // Утверждение (assert)
            var articles = result.Articles.ToList();
            Assert.IsTrue(articles.Count == 2);
            Assert.AreEqual(articles[0].Name, "Хуйня4");
            Assert.AreEqual(articles[1].Name, "Хуйня5");
        }
예제 #35
0
        public void SetUp()
        {
            _fakeUserService = new Mock<IUserService>();
            _fakeArticleService = new Mock<IArticleService>();
            _fakeConfigService = new Mock<IConfigurationService>();

            _testArticle = new Article
            {
                User = new User(),
                Id = 1,
                Likes = new List<Like>(),
                Comments = new List<Comment>(),
                Body = "Test!",
                CreatedBy = 1,
                DateCreated = DateTime.Now,
                DateUpdated = DateTime.Now,
                Title = "Test Article",
                UpdatedBy = 1,
                User1 = new User()
            };

            _articleController = new ArticleController(_fakeArticleService.Object, _fakeUserService.Object, _fakeConfigService.Object);

            var controllerContext = new Mock<ControllerContext>();
            controllerContext.SetupGet(x => x.HttpContext.User.Identity.Name).Returns("*****@*****.**");
            _articleController.ControllerContext = controllerContext.Object;
        }
예제 #36
0
        public void Can_Send_Pagination_View_Model()
        {
            // Организация (arrange)
            var mock = new Mock<IArticleRepository>();
            mock.Setup(m => m.Articles).Returns(new List<Article>
            {
                new Article("375B7984-4C3F-446C-A8A3-E86077AADD3B") { Name = "Хуйня1", Description = "Статья про хуй", Content = "Жил был хуй", Tags = new List<Tag>(2)
                {
                    new Tag{ TagId = Guid.NewGuid(), Name = "хуй" },
                    new Tag{ TagId = Guid.NewGuid(), Name = "член" },
                    new Tag{ TagId = Guid.NewGuid(), Name = "писька" },
                    new Tag{ TagId = Guid.NewGuid(), Name = "пеннис" }
                }},
                new Article("375B7984-4C3F-446C-A8A3-E86077AADD3B") { Name = "Хуйня2", Description = "Статья про хуй", Content = "Жил был хуй", Tags = new List<Tag>(2)
                {
                    new Tag{ TagId = Guid.NewGuid(), Name = "хуй" },
                }},
                new Article("375B7984-4C3F-446C-A8A3-E86077AADD3B") { Name = "Хуйня3", Description = "Статья про хуй", Content = "Жил был хуй", Tags = new List<Tag>(2)
                {
                    new Tag{ TagId = Guid.NewGuid(), Name = "член" },
                }},
                new Article("375B7984-4C3F-446C-A8A3-E86077AADD3B") { Name = "Хуйня4", Description = "Статья про хуй", Content = "Жил был хуй", Tags = new List<Tag>(2)
                {
                    new Tag{ TagId = Guid.NewGuid(), Name = "писька" },
                }},
                new Article("375B7984-4C3F-446C-A8A3-E86077AADD3B") { Name = "Хуйня5", Description = "Статья про хуй", Content = "Жил был хуй", Tags = new List<Tag>(2)
                {
                    new Tag{ TagId = Guid.NewGuid(), Name = "пеннис" },
                }},
            });
            var controller = new ArticleController(mock.Object) { _pageSize = 3 };

            // Действие (act)
            var result = (ArticleListViewModel)controller.List(string.Empty, 2).Model;

            // Утверждение (assert)
            var pageInfo = result.PagingInfo;
            Assert.AreEqual(pageInfo.CurrentPage, 2);
            Assert.AreEqual(pageInfo.ItemsPerPage, 3);
            Assert.AreEqual(pageInfo.TotalItems, 5);
            Assert.AreEqual(pageInfo.TotalPages, 2);
        }