コード例 #1
0
        public async Task <IActionResult> Post([FromBody] SetCardDto value)
        {
            var entityDto = _mapper.Map <SetCardDto, set_card>(value);

            entityDto.CreatedAt  = DateTime.Now;
            entityDto.UpdatedAt  = DateTime.Now;
            entityDto.IsValid    = true;
            entityDto.IsRecharge = value.InCome == "是";
            if (User.Identity is ClaimsIdentity identity)
            {
                entityDto.CreatedBy = identity.Name ?? "admin";
            }
            _setCardRpt.Add(entityDto);
            _setCardRpt.Commit();
            return(new OkObjectResult(value));
        }
コード例 #2
0
        public async Task <IActionResult> Put(int id, [FromBody] SetCardDto value)
        {
            var single = _setCardRpt.GetSingle(id);

            if (single == null)
            {
                return(NotFound());
            }
            //更新字段内容
            single.UpdatedAt  = DateTime.Now;
            single.IsRecharge = value.InCome == "是";
            single.Level      = value.Level;
            single.Name       = value.Name;
            single.Remark     = value.Remark;
            single.CardFee    = value.CardFee;
            if (User.Identity is ClaimsIdentity identity)
            {
                single.CreatedBy = identity.Name ?? "admin";
            }
            _setCardRpt.Commit();
            return(new NoContentResult());
        }