コード例 #1
0
        public void CreateSupplement_ModelIsValid_ReturnCreated()
        {
            var supplementDto = new SupplementDto();
            var supplement    = Mapper.Map <SupplementDto, Supplement>(supplementDto);

            unitOfWork.Setup(uow => uow.Supplements.Add(supplement));
            unitOfWork.Setup(uow => uow.Complete());

            var result = controller.CreateSupplement(supplementDto);

            Assert.That(result, Is.InstanceOf(typeof(CreatedNegotiatedContentResult <SupplementDto>)));
        }
コード例 #2
0
        public IActionResult Supplement(int id, IFormCollection collection)
        {
            var dto = new SupplementDto();

            TryUpdateModelAsync(dto);

            if (ModelState.IsValid)
            {
                var result = _service.Supplement(id, dto);
                if (result > 0)
                {
                    return(RedirectToAction(nameof(Index)));
                }

                ModelState.AddModelError(string.Empty, "更新失败");
            }

            return(View(dto));
        }
コード例 #3
0
        /// <summary>
        /// 完善资料
        /// </summary>
        /// <param name="id"></param>
        /// <param name="dto"></param>
        /// <returns></returns>
        public int Supplement(int id, SupplementDto dto)
        {
            var entity = _db.Load <Approval>(id);

            if (entity == null)
            {
                return(0);
            }

            entity.OrderNo             = dto.OrderNo;
            entity.IsHasInvoice        = dto.IsHasInvoice;
            entity.TaxPoint            = dto.TaxPoint;
            entity.PaymentInfo         = dto.PaymentInfo;
            entity.ActualClosingAmount = dto.ActualClosingAmount;
            entity.ActualClosingProfit = dto.ActualClosingProfit;
            entity.Collections         = dto.Collections;
            entity.CompleteAt          = dto.CompleteAt;

            return(_db.Update(entity));
        }
コード例 #4
0
        public IHttpActionResult CreateSupplement(SupplementDto supplementDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            if (supplementDto.ConsumedAmount == null)
            {
                supplementDto.ConsumedAmount = 0;
            }

            var supplement = Mapper.Map <SupplementDto, Supplement>(supplementDto);

            unitOfWork.Supplements.Add(supplement);
            unitOfWork.Complete();

            supplementDto.Id = supplement.Id;

            return(Created(new Uri(Request.RequestUri + "/" + supplement.Id), supplementDto));
        }
コード例 #5
0
        public IHttpActionResult UpdateSupplement(int id, SupplementDto supplementDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            if (supplementDto.ConsumedAmount == null)
            {
                supplementDto.ConsumedAmount = 0;
            }

            var supplementInDb = unitOfWork.Supplements.SingleOrDefault(s => s.Id == id);

            if (supplementInDb == null)
            {
                return(NotFound());
            }

            Mapper.Map(supplementDto, supplementInDb);
            unitOfWork.Complete();

            return(Ok());
        }