Beispiel #1
0
        public ActionResult PostStatus([FromBody] StatusDto statusDto)
        {
            var response = _service.Add(statusDto);

            _service.Save(response);

            return(new OkObjectResult(response["Output"]));
        }
Beispiel #2
0
        public async void SubmitClick(object o, EventArgs eventargs)
        {
            bool isPrivate = false;
            var  userToken = UserTokenUtil.GetToken(this);

            if (et_content.Text.Trim().Length == 0)
            {
                return;
            }
            rg_isPrivate.CheckedChange += (s, e) =>
            {
                if (e.CheckedId == rb_true.Id)
                {
                    isPrivate = true;
                }
                else if (e.CheckedId == rb_false.Id)
                {
                    isPrivate = false;
                }
            };
            if (userToken.IsExpire)
            {
                Android.Support.V7.App.AlertDialog.Builder alertDialog = new Android.Support.V7.App.AlertDialog.Builder(this)
                                                                         .SetTitle("登录提示")
                                                                         .SetMessage("未登录或登录token已经过期")
                                                                         .SetPositiveButton("授权", (s1, e1) =>
                {
                    StartActivity(new Intent(this, typeof(loginactivity)));
                })
                                                                         .SetNegativeButton("取消", (s1, e1) =>
                {
                    return;
                });
                alertDialog.Create().Show();
            }
            var dialog = new ProgressDialog(this);

            dialog.SetProgressStyle(ProgressDialogStyle.Spinner);
            dialog.SetCancelable(false);
            dialog.SetCanceledOnTouchOutside(false);
            dialog.SetTitle(Resources.GetString(Resource.String.bookmark_add));
            dialog.SetMessage("提交中.......");
            dialog.Show();
            var result = await StatusService.Add(userToken, et_content.Text.Trim(), isPrivate);

            if (result.Success)
            {
                dialog.Hide();
                AlertUtil.ToastShort(this, "发布成功");
                ActivityCompat.FinishAfterTransition(this);
            }
            else
            {
                dialog.Hide();
                AlertUtil.ToastShort(this, result.Message);
            }
        }
        public void StatusServiceAdd_UnitOfWorkAddAndComplete_ReturnsUnitOfWorkAddAndComplete()
        {
            var statusDto = new StatusDto();
            var entity    = Mapper.Map <StatusDto, Status>(statusDto);

            _statusService.Add(statusDto);

            _uow.Received().Statuses.Add(entity);
            _uow.Received().Complete();
        }
Beispiel #4
0
        public void AddStatus()
        {
            _service.Add(new StatusDto {
                Id = "3", Name = "name3"
            });
            _service.Save(_dbContextMock);

            var result = _service.GetAll();
            var count  = result.Count();

            Assert.AreEqual(3, count);
        }
        public void Add_New_Status()
        {
            var mockSet = BuildMock();
            var mockCtx = new Mock <LibraryDbContext>();

            mockCtx.Setup(c => c.Statuses).Returns(mockSet.Object);
            var sut = new StatusService(mockCtx.Object);

            sut.Add(new Status());

            mockCtx.Verify(s => s.Add(It.IsAny <Status>()), Times.Once());
            mockCtx.Verify(c => c.SaveChanges(), Times.Once());
        }
Beispiel #6
0
 // POST api/<controller>
 public IHttpActionResult Post([FromBody] ITS_Status status)
 {
     return(Utils.Response(Service.Add(status), HttpStatusCode.InternalServerError, string.Format("Could not create status {0}.", status.Status), Request.RequestUri.AbsoluteUri));
 }