コード例 #1
0
        public void post_validation_check()
        {
            Mock <IPostDal> mock        = new Mock <IPostDal>();
            PostManager     postManager = new PostManager(mock.Object);

            postManager.Add(new Post());
        }
コード例 #2
0
        public ActionResult Add(PostViewModel postViewModel)
        {
            PostManager postManager = new PostManager();

            postManager.Add(postViewModel.post);
            postManager.saveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #3
0
        public int AddTopicPost(TopicPostViewModel topicPost)
        {
            try
            {
                TopicPost _topicPost = ObjectMapper.Map <TopicPostViewModel, TopicPost>(topicPost);

                TopicPost newTopicPost = PostManager.Add(_topicPost);
                return(newTopicPost.Id);
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex, PolicyNameType.ExceptionReplacing);
                return(0);
            }
        }
コード例 #4
0
        public Post Add(PostModel input)
        {
            Post post = new Post
            {
                Active      = false,
                Content     = input.Content,
                Date        = input.Date.Value,
                DateCreated = DateTime.UtcNow,
                Title       = input.Title
            };

            post = PostManager.Add(post);

            return(post);
        }
コード例 #5
0
ファイル: PostController.cs プロジェクト: leanphon/Mis.Web
        public ActionResult CreateEntity(PostInfo model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(
                           new OperateResult
                {
                    content = Model.Utility.GetModelStateErrors(ModelState),
                },
                           JsonRequestBehavior.AllowGet
                           ));
            }

            OperateResult or = PostManager.Add(model);

            return(Json(or, JsonRequestBehavior.AllowGet));
        }
コード例 #6
0
        public bool PostAddStub()
        {
            for (var i = 0; i < PostStubSize; i++)
            {
                PostInfo e = new PostInfo();

                e.name = "Post-" + i;
                OperateResult or = PostManager.Add(e);
                if (or.status == OperateStatus.Error)
                {
                    StackTrace st  = new StackTrace(new StackFrame(true));
                    string     msg = $"App Trace >>> in file: {st.GetFrame(0).GetFileName()} " +
                                     $"line {st.GetFrame(0).GetFileLineNumber()} message: {or.content}";
                    Trace.WriteLine(msg);
                    return(false);
                }
            }

            return(true);
        }
コード例 #7
0
        public void CreatePost()
        {
            GetMediaPaths();
            var post = new Post();

            if (!string.IsNullOrEmpty(tbTitle.Text))
            {
                post.Title = tbTitle.Text;
            }
            if (!string.IsNullOrEmpty(tbDes.InnerText))
            {
                post.Description = tbDes.InnerText;
            }
            if (!string.IsNullOrWhiteSpace(tbPrice.Text))
            {
                post.Price = double.Parse(tbPrice.Text);
            }
            if (!string.IsNullOrWhiteSpace(tbAcreage.Text))
            {
                post.Acreage = int.Parse(tbAcreage.Text);
            }
            if (!string.IsNullOrWhiteSpace(tbEprice.Text))
            {
                post.ElectricityPrice = double.Parse(tbEprice.Text);
            }
            if (!string.IsNullOrWhiteSpace(tbWprice.Text))
            {
                post.WaterPrice = double.Parse(tbWprice.Text);
            }
            if (!string.IsNullOrWhiteSpace(tbMaxmem.Text))
            {
                post.MaxMember = int.Parse(tbMaxmem.Text);
            }
            post.WithHost      = cbWithHost.Checked;
            post.SelfContained = cbSelfContained.Checked;
            if (!string.IsNullOrEmpty(tbAddress.Text))
            {
                post.HouseAddress = tbAddress.Text;
            }
            if (dlLineId.SelectedValue != null && dlLineId.SelectedValue.Length > 0)
            {
                post.LineId = int.Parse(dlLineId.SelectedValue);
            }
            if (dlDistrictId.SelectedValue != null && dlDistrictId.SelectedValue.Length > 0)
            {
                post.DistrictId = int.Parse(dlDistrictId.SelectedValue);
            }
            if (dlCityId.SelectedValue != null && dlCityId.SelectedValue.Length > 0)
            {
                post.CityId = int.Parse(dlCityId.SelectedValue);
            }
            if (!string.IsNullOrEmpty(tbCoordinatesX.Text))
            {
                post.CoordinatesX = tbCoordinatesX.Text;
            }
            if (!string.IsNullOrEmpty(tbCoordinatesY.Text))
            {
                post.CoordinatesY = tbCoordinatesY.Text;
            }
            if (!string.IsNullOrEmpty(tbPhoneNumber.Text))
            {
                post.PhoneNumber = tbPhoneNumber.Text;
            }
            if (dlCityId.SelectedItem != null && !string.IsNullOrEmpty(dlCityId.SelectedValue))
            {
                post.CityId = int.Parse(dlCityId.SelectedValue);
            }
            if (dlDistrictId.SelectedItem != null && !string.IsNullOrEmpty(dlDistrictId.SelectedValue))
            {
                post.DistrictId = int.Parse(dlDistrictId.SelectedValue);
            }
            if (dlLineId.SelectedItem != null && !string.IsNullOrEmpty(dlLineId.SelectedValue))
            {
                post.LineId = int.Parse(dlLineId.SelectedValue);
            }
            post.ImagePaths = ImagePaths;
            post.VideoPaths = VideoPaths;
            post.UserId     = int.Parse(Session["UserId"].ToString());
            var result = PostManager.Add(post);

            if (result != null)
            {
                Response.Redirect("DetailPost.aspx?id=" + result.Id + "");
            }
        }
コード例 #8
0
 public void Post([FromBody] Post value)
 {
     _repo.Add(value);
 }