public void CreatePostTransport(PostTransportCreateDto postTransportCreateDto, ApplicationUser user) { Location locationFrom = new Location() { Country = _countryRepository.GetByName(postTransportCreateDto.CountryFrom), Locality = _localityRepository.GetByName(postTransportCreateDto.LocalityFrom) }; Location locationTo = new Location() { Country = _countryRepository.GetByName(postTransportCreateDto.CountryTo), Locality = _localityRepository.GetByName(postTransportCreateDto.LocalityTo) }; TransportSpecification transportSpecification = new TransportSpecification() { Description = postTransportCreateDto.TransportDescription, WeightCapacity = postTransportCreateDto.WeightCapacity, VolumeCapacity = postTransportCreateDto.VolumeCapacity }; var postFactory = new PostFactory(); var post = postFactory.CreateNewPost(user, postTransportCreateDto.DateFrom, postTransportCreateDto.DateTo, locationFrom, locationTo, postTransportCreateDto.PostTransportTypes, postTransportCreateDto.Price, postTransportCreateDto.AdditionalInfo, transportSpecification); _locationRepository.Save(locationFrom); _locationRepository.Save(locationTo); _transportSpecRepository.Save(transportSpecification); _postTransportRepository.Save(post as PostTransport); }
protected void Page_Load(object sender, EventArgs e) { m_ConfigHelper = new ConfigHelper(); m_WebLogService = new WebLogService(); m_PostFactory = new PostFactory(); m_MemberFactory = new MemberFactory(); m_AuthFactory = new AuthFactory(); m_HttpHelper = new HttpHelper(); m_SessionHelper = new SessionHelper(); m_AccountingFactory = new AccountingFactory(); m_AuthService = m_AuthFactory.GetAuthService(); m_MemberService = m_MemberFactory.GetMemberService(); m_PostService = m_PostFactory.GetPostService(); m_AccountingService = m_AccountingFactory.GetAccountingService(); if (!IsPostBack) { InitDDL(); ShowMode(); fillGridView(); new Thread(new ThreadStart(ApiUtil.UpdateMemberToServer)).Start(); new Thread(new ThreadStart(() => ApiUtil.UpdateFileToServer(Server.MapPath("../../App_Data/upload/")))).Start(); new Thread(new ThreadStart(() => ApiUtil.UpdatePostToServer(2))).Start(); //LoadTotalCommission(); } }
/// <summary> /// 取得主視覺的內容 /// </summary> /// <param name="server"></param> /// <param name="mainAdvNodeId">主視覺設定檔代碼</param> /// <returns>主視覺的內容</returns> public static string GetMainAdvContent(HttpServerUtility server, int mainAdvNodeId) { string content = string.Empty; PostFactory postFactory = new PostFactory(); IPostService postService = postFactory.GetPostService(); NodeVO nodeVO = postService.GetNodeById(mainAdvNodeId); if (nodeVO != null) { if (nodeVO.UType == NodeVO.UnitType.Flash) { string advFile = server.MapPath("~/template/") + "main-adv-flash01.txt"; string fileContent = File.ReadAllText(advFile, System.Text.Encoding.UTF8); content = fileContent.Replace("(#FILENAME)", nodeVO.PicFileName); } //暫時不用圖片,僅flash //else if (nodeVO.UType == NodeVO.UnitType.Pic) //{ // string advFile = server.MapPath("~/template/") + "main-adv-pic01.txt"; // string fileContent = File.ReadAllText(advFile, System.Text.Encoding.UTF8); // content = fileContent.Replace("(#FILENAME)", nodeVO.PicFileName); //} } return(content); }
public void CreatePostCargo(PostCargoCreateDto createPostCargoDto, ApplicationUser user) { Location locationFrom = new Location() { Country = _countryRepository.GetByName(createPostCargoDto.CountryFrom), Locality = _localityRepository.GetByName(createPostCargoDto.LocalityFrom) }; Location locationTo = new Location() { Country = _countryRepository.GetByName(createPostCargoDto.CountryTo), Locality = _localityRepository.GetByName(createPostCargoDto.LocalityTo) }; CargoSpecification cargoSpecification = new CargoSpecification() { Description = createPostCargoDto.CargoDescription, Weight = createPostCargoDto.CargoWeight, Volume = createPostCargoDto.CargoVolume }; var postFactory = new PostFactory(); var post = postFactory.CreateNewPost(user, createPostCargoDto.DateFrom, createPostCargoDto.DateTo, locationFrom, locationTo, createPostCargoDto.PostTransportTypes, createPostCargoDto.Price, createPostCargoDto.AdditionalInfo, cargoSpecification); _locationRepository.Save(locationFrom); _locationRepository.Save(locationTo); _cargospecRepository.Save(cargoSpecification); _postCargoRepository.Save(post as PostCargo); }
public void LesPoster_SkalGiRiktigAntall() { var postFactory = new PostFactory(); var poster = postFactory.Les(Constants.Område.Oscarsborg); Assert.AreEqual(30, poster.Count); }
public void Setup() { _identityFacade = new Mock <IIdentityFacade>(); _dataConverter = new Mock <IDataConverter>(); _postFactory = new PostFactory(_identityFacade.Object, _dataConverter.Object); _identityFacade.Setup(x => x.GetUserName()).Returns("Shrook"); _identityFacade.Setup(x => x.GetUserId()).Returns("22"); }
protected void Page_Load(object sender, EventArgs e) { m_PostFactory = new PostFactory(); m_PostService = m_PostFactory.GetPostService(); if (!IsPostBack) { LoadUI(); } }
protected void Page_Load(object sender, EventArgs e) { m_PostFactory = new PostFactory(); m_PostService = m_PostFactory.GetPostService(); if (!IsPostBack) { IList <NodeVO> storeList = m_PostService.GetNodeListByParentName("店家"); ltlTitle.Text = string.Format("<title> 品讚行動通訊聯合系統-{0}</title>", storeList[0].Name); } }
protected void Page_Load(object sender, EventArgs e) { m_WebLogService = new WebLogService(); m_PostFactory = new PostFactory(); m_PostService = m_PostFactory.GetPostService(); if (!IsPostBack) { GetList(); ShowMode(); } }
protected void Page_Load(object sender, EventArgs e) { m_WebLogService = new WebLogService(); m_PostFactory = new PostFactory(); m_PostService = m_PostFactory.GetPostService(); if (!IsPostBack) { pnlContent.Visible = false; fillGridView(); ShowMode(); } }
public void FACTORY_Can_create_valid_post() { //Arrange //Act var post = PostFactory.factory("Title", "Body", null); //Assert Assert.IsNotNullOrEmpty(post.title); Assert.IsNotNullOrEmpty(post.body); Assert.IsNotNullOrEmpty(post.preview); Assert.LessOrEqual(post.preview.Length, 50); }
public void SavePost(PostDetailDTO post) { var postEntity = PostFactory.Create(post.Id, 1, post.Title, post.Subtitle, post.Slug, post.Content); if (postEntity.Id == 0) { PostRepository.Add(postEntity); } else { PostRepository.Update(postEntity); } }
public Post AddPost(Web.Models.PostVM newPostVM) { Post post = PostFactory.factory(newPostVM.title, newPostVM.body, newPostVM.tags); //new Post(); post.body = newPostVM.body; post.title = newPostVM.title; if (!(null == newPostVM.tags)) { post.tags = new List <string>(newPostVM.tags); } return(post); }
public void LesPosterMedKoder_SkalGiKodePåAllePoster() { var postFactory = new PostFactory(); var poster = postFactory.Les(Constants.Område.Oscarsborg); var feilKodeLengde = poster.Select(x => new { x.Navn, x.HemmeligKode, KodeLengde = x.HemmeligKode.Length }).Where(x => x.KodeLengde < 4); Assert.IsFalse(feilKodeLengde.Any(), "Alle skal ha 5 bokstaver i hemmelig kode"); var alleKoderErUnike = poster.All(x => !poster.Any(y => y.PostId != x.PostId && y.HemmeligKode == x.HemmeligKode)); Assert.IsTrue(alleKoderErUnike, "Alle koder skal være unike"); }
protected void Page_Load(object sender, EventArgs e) { m_PostFactory = new PostFactory(); m_PostService = m_PostFactory.GetPostService(); if (!Page.IsPostBack) { if (m_SessionHelper.LoginUser != null) { lblMsg.Text = m_SessionHelper.LoginUser.FullNameInChinese + "@" + HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"] + " > 歡迎您再次登入!今天是民國" + (ConvertUtil.UtcDateTimeToTaiwanDateTime(DateTime.UtcNow).Year - 1911).ToString() + "年" + ConvertUtil.UtcDateTimeToTaiwanDateTime(DateTime.UtcNow).Month.ToString("00") + "月" + ConvertUtil.UtcDateTimeToTaiwanDateTime(DateTime.UtcNow).Day.ToString("00") + "日"; } IList <NodeVO> storeList = m_PostService.GetNodeListByParentName("店家"); ltlTitle.Text = string.Format("<title> 品讚行動通訊聯合系統-{0}</title>", storeList[0].Name); ltlTitle2.Text = string.Format("<品讚行動通訊聯合系統-{0}", storeList[0].Name); } }
public void TestCaseInit() { m_AuthFactory = new AuthFactory(); m_PostFactory = new PostFactory(); m_SystemFactory = new SystemFactory(); m_StorageFactory = new StorageFactory(); m_MemberFactory = new MemberFactory(); m_AccountingFactory = new AccountingFactory(); m_AuthService = m_AuthFactory.GetAuthService(); m_PostService = m_PostFactory.GetPostService(); m_TemplateService = m_SystemFactory.GetTemplateService(); m_SystemService = m_SystemFactory.GetSystemService(); m_MessageService = m_PostFactory.GetMessageService(); m_StorageFileService = m_StorageFactory.GetStorageFileService(); m_MemberService = m_MemberFactory.GetMemberService(); m_AccountingService = m_AccountingFactory.GetAccountingService(); }
public void LesPosterMedKoder_SkalGiSammeResultatHverGang_EllersBlirDetTull() { var postFactory = new PostFactory(); var poster = postFactory.Les(Constants.Område.Oscarsborg); var backup = poster.Select(x => new { Post = x.Navn, Kode = x.HemmeligKode }); var fasit = JsonConvert.SerializeObject(backup); for (int i = 0; i < 10; i++) { poster = postFactory.Les(Constants.Område.Oscarsborg); backup = poster.Select(x => new { Post = x.Navn, Kode = x.HemmeligKode }); var json = JsonConvert.SerializeObject(backup); Assert.AreEqual(fasit, json, "Det blei ikke samme resultat i runde " + i); } }
protected void Page_Load(object sender, EventArgs e) { m_ConfigHelper = new ConfigHelper(); m_WebLogService = new WebLogService(); m_PostFactory = new PostFactory(); m_AuthFactory = new AuthFactory(); m_SessionHelper = new SessionHelper(); m_AuthService = m_AuthFactory.GetAuthService(); m_PostService = m_PostFactory.GetPostService(); if (!IsPostBack) { InitDDL(); pnlContent.Visible = false; fillGridView(); ShowMode(); } }
public void InitializePosts() { var authorId = _context.Authors.Select(a => a.Id).First(); var randomNumberGenerator = new Random(); var blogPostSeed = randomNumberGenerator.Next(25, 50); for (int i = 0; i < blogPostSeed; i++) { var title = String.Format("Blog Post {0}", i); var subTitle = String.Format("Sub Title For Blog Post {0}", i); var slug = String.Format("blog-post-{0}", i); var post = PostFactory.Create(0, authorId, title, subTitle, slug, ""); post.InsertDate = DateTime.UtcNow; _context.Posts.Add(post); } _context.SaveChanges(); }
public static string GetMainTopAdvPic(HttpServerUtility server, int m_PostId1) { string content = string.Empty; WebPageHelper webPageHelper = new WebPageHelper(); PostFactory postFactory = new PostFactory(); IPostService postService = postFactory.GetPostService(); PostVO podeVO = postService.GetPostById(m_PostId1); if (podeVO != null) { string advFile = server.MapPath("~/template/") + "main-adv-pic01.txt"; string fileContent = File.ReadAllText(advFile, System.Text.Encoding.UTF8); content = fileContent.Replace("(#FILENAME)", webPageHelper.GetContent(podeVO, "PicFileName")); } return(content); }
public async override Task <PostDTO> AddAsync(PostDTO postDTO) { if (postDTO == null) { throw new ArgumentException(_resources.GetStringResource(LocalizationKeys.Application.validation_No_Records_Found_Error)); } Post post = PostFactory.CreatePost(postDTO.Title, postDTO.Content, postDTO.BlogId); if (_validator.IsValid <Post>(post)) { _postRepository.Add(post); await _postRepository.UnitOfWork.CommitAsync(); return(post.ProjectedAs <PostDTO>()); } else { throw new ApplicationValidationErrorsException(_validator.GetInvalidMessages <Post>(post)); } }
protected void Page_Load(object sender, EventArgs e) { m_WebLogService = new WebLogService(); m_PostFactory = new PostFactory(); m_MemberFactory = new MemberFactory(); m_AuthFactory = new AuthFactory(); m_HttpHelper = new HttpHelper(); m_SessionHelper = new SessionHelper(); m_AccountingFactory = new AccountingFactory(); m_AuthService = m_AuthFactory.GetAuthService(); m_MemberService = m_MemberFactory.GetMemberService(); m_PostService = m_PostFactory.GetPostService(); m_AccountingService = m_AccountingFactory.GetAccountingService(); if (!IsPostBack) { ////先更新到今天之前的結帳 m_AccountingService.UpdateCash(); txtDate.Text = ConvertUtil.UtcDateTimeToTaiwanDateTime(DateTime.UtcNow).ToString("yyyy/MM/dd"); ShowMode(); LoadDataToUI(); } }
public async Task When_GET_blog_posts_for_author_name_Then_200_OK_with_expected_posts_are_returned() { var user1 = UserFactory.CreateUser("User 1"); var user2 = UserFactory.CreateUser("User 2"); var user3 = UserFactory.CreateUser("User 3"); var post1 = PostFactory.CreatePost("Post 1", new[] { user2, user3 }); var post2 = PostFactory.CreatePost("Post 2", new[] { user1, user2 }); var post3 = PostFactory.CreatePost("Post 3", new[] { user1, user3 }); using (var context = CreateContext()) { context.Users.Add(user1); context.Users.Add(user2); context.Users.Add(user3); context.Posts.Add(post1); context.Posts.Add(post2); context.Posts.Add(post3); await context.SaveChangesAsync(); } var(getBlogPostsResponse, httpResponse) = await _client.GetWithResponseAsync <GetBlogPostsResponse>($"{BASE_ROUTE}?author={user1.Name}"); Assert.Multiple(() => { Assert.That(httpResponse.StatusCode, Is.EqualTo(HttpStatusCode.OK), "Invalid status code"); Assert.That(getBlogPostsResponse, Is.Not.Null, "Response is null"); Assert.That(getBlogPostsResponse.Posts, Is.Not.Null, "Post result is null"); Assert.That(getBlogPostsResponse.Posts.Count(), Is.EqualTo(2), "Invalid post count"); Assert.That(getBlogPostsResponse.Posts.Any(p => (p.PostId, p.Title) == (post2.PostId, post2.Title)), "Expected post not returned"); Assert.That(getBlogPostsResponse.Posts.Any(p => (p.PostId, p.Title) == (post3.PostId, post3.Title)), "Expected post not returned"); }); }
public DataService(HtmlWebWrapper htmlWebWrapper, PostFactory postFactory) { this.htmlWebWrapper = htmlWebWrapper; this.postFactory = postFactory; }
// POST api/<controller> public void Post([FromBody] IncomingBlog blog) { _service.Upsert(PostFactory.CreatePost(blog.Title, blog.Body)); }
public void SetUp() { this.postFactory = new PostFactory(); }
public WebPageHelper() { m_PostFactory = new PostFactory(); m_PostService = m_PostFactory.GetPostService(); }
private void btnGo_Click(object sender, EventArgs e) { if (!_blogSelected) { MessageBox.Show("First connect to blog from File>Connect!"); return; } if (lvItems.SelectedItems.Count == 0) { MessageBox.Show("Select items to transfer!"); return; } var programOptionsFactory = new ProgramOptionsFactory(); _options = programOptionsFactory.Get(); _stopWatch = new Stopwatch(); _stopWatch.Start(); EnDisItems(false); lblDateTime.Text = "Started at " + DateTime.Now.ToLongTimeString(); using (var dal = new Dal(MySqlConnectionString)) { _blogCache = new BlogCache(dal); if (_options.UseCache) { SetStatus("Loading present posts and tags in the blog(this may take some time)..."); Application.DoEvents(); _blogCache.Start(_options.BlogUrl); Application.DoEvents(); } SetStatus("Ready"); ResetBarStatus(true); barStatus.Maximum = lvItems.SelectedItems.Count; _postFactory = new PostFactory( SiteConfig, new Ftp(FtpConfiguration), _blogCache, dal, _options); var items = ItemsFromListView(lvItems.SelectedItems); _postFactory.PostCreated += PostCreated; _postFactory.PostBeingCreated += PostBeingCreated; _postFactory.PostsCreated += PostsCreated; _postFactory.PostCreationStopped += PostCreationStopped; _postFactory.Create(items); } }
public IdeasController(UserFactory uf, PostFactory pf, LikeFactory lkf) { userFactory = uf; postFactory = pf; likeFactory = lkf; }
/// <summary> /// 同步到Server /// </summary> public static void UpdateFileToServer(string filePath) { PostFactory m_PostFactory = new PostFactory(); IPostFileService m_PostFileService = m_PostFactory.GetPostFileService(); ConfigHelper m_ConfigHelper = new ConfigHelper(); WebUtility m_WebUtility = new WebUtility(); if (string.IsNullOrEmpty(m_ConfigHelper.PostFileApiUrl)) { return; } Dictionary <string, string> conditions = new Dictionary <string, string>(); conditions.Add("NeedUpdate", "true"); IList <FileVO> list = m_PostFileService.GetFileList(conditions); if (list != null && list.Count > 0) { foreach (FileVO vo in list) { try { FileVO fileVO = m_PostFileService.GetFileById(vo.FileId); if (fileVO.IsUpdatingToServer) { continue; } FileDto dto = new FileDto(vo); //狀態為刪除 if (dto.Flag == 0) { vo.IsUpdatingToServer = true; m_PostFileService.UpdateFile(vo); if (dto.ServerId > 0) { //有serverId就去server刪除 string url = m_ConfigHelper.PostFileApiUrl + "/" + dto.ServerId.ToString(); WebRequest request = ApiUtil.Post(url, "DELETE", ""); using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { if (response.StatusCode == HttpStatusCode.OK || response.StatusCode == HttpStatusCode.Gone || response.StatusCode == HttpStatusCode.NoContent) { vo.NeedUpdate = false; vo.IsUpdatingToServer = false; m_PostFileService.UpdateFile(vo); } } } else { //沒有serverId就直接標記已更新 vo.NeedUpdate = false; vo.IsUpdatingToServer = false; m_PostFileService.UpdateFile(vo); } } else { vo.IsUpdatingToServer = true; m_PostFileService.UpdateFile(vo); WebRequest request = ApiUtil.Post <FileDto>(m_ConfigHelper.PostFileApiUrl, "POST", dto); string responseInfo = string.Empty; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { if (response.StatusCode == HttpStatusCode.Created) { using (Stream stream = response.GetResponseStream()) { responseInfo = (new StreamReader(stream)).ReadToEnd().Trim(); FileDto newFileDto = JsonConvert.DeserializeObject <FileDto>(responseInfo); vo.IsUpdatingToServer = false; vo.NeedUpdate = false; vo.ServerId = newFileDto.FileId; m_PostFileService.UpdateFile(vo); //成功的話在ftp檔案 m_WebUtility.UploadFileToFTP(Path.Combine(filePath, vo.FileName)); } } } } } catch (Exception ex) { vo.IsUpdatingToServer = false; m_PostFileService.UpdateFile(vo); string error = ex.ToString(); } } } }
public Writer(PostFactory factory) { _factory = factory; }