public async Task <IActionResult> PostClear([FromBody] fw_clean value) { int oldState = int.Parse(value.CreatedBy); string createBy = string.Empty; if (User.Identity is ClaimsIdentity identity) { createBy = identity.Name ?? "test"; } value.CreatedBy = createBy; value.IsValid = true; value.CleanTime = DateTime.Now; value.IsOverStay = false; using (var tran = _context.Database.BeginTransaction()) { try { //增加扫房日志 _cleanRepository.Add(value); _cleanRepository.Commit(); //新增房态日志 _fwStatelogRepository.Add(new fw_statelog() { HouseCode = value.HouseCode, OldState = oldState, NewState = 1001, OrderNo = string.Empty, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now, IsValid = true, CreatedBy = createBy }); _fwStatelogRepository.Commit(); //修改房屋状态 var house = _fwHouseinfoRpt.GetSingle(f => f.Code == value.HouseCode); if (house != null) { house.State = 1001; } _fwHouseinfoRpt.Commit(); tran.Commit(); } catch (Exception ex) { tran.Rollback(); return(new BadRequestResult()); } } return(new OkObjectResult(value)); }
public async Task <IActionResult> Post([FromBody] fw_clean value) { value.CreatedAt = DateTime.Now; value.UpdatedAt = DateTime.Now; value.IsValid = true; if (User.Identity is ClaimsIdentity identity) { value.CreatedBy = identity.Name ?? "admin"; } _fwCleanRpt.Add(value); _fwCleanRpt.Commit(); return(new OkObjectResult(value)); }
public async Task <IActionResult> Put(int id, [FromBody] fw_clean value) { var single = _fwCleanRpt.GetSingle(id); if (single == null) { return(NotFound()); } //更新字段内容 single.UpdatedAt = DateTime.Now; if (User.Identity is ClaimsIdentity identity) { single.CreatedBy = identity.Name ?? "admin"; } _fwCleanRpt.Commit(); return(new NoContentResult()); }