public async Task GetClient_Test() { // Act // Create record Manually var newClient = new Client { Name = "Sergio Peralta", Email = "*****@*****.**", Code = "AAA132", Celphone = "99989292", Phone = "1231312", Sexo = Sexo.Masculino, }; await UsingDbContextAsync(async context => { context.Client.Add(newClient); await context.SaveChangesAsync(); }); var input = new GetClientInput { Id = 1 }; //Arrage var output = await _clientAppService.GetClient(input); // Assert output.ShouldNotBeNull(); }
public async Task <IActionResult> Check(LetterCheckModel model) { var result = new ResultEntity(); var client = await _clientAppService.GetClient(model.DeviceCode); if (client == null) { result.Message = "未登记的客户端,无法使用此功能"; } else { var placeId = client.PlaceId; result = await _letterAppService.GetCheckInfo(CurrentUser.UserId, placeId, model.BeginTime, model.EndTime); } return(Json(result)); }
public async Task <ActionResult <ClientDto> > GetClient(int Id) { if (!ModelState.IsValid) { return(BadRequest(ModelStateErrors)); } var result = await _clientAppService.GetClient(Id); return(result); }
public async Task <IActionResult> Login(LoginViewModel model, string returnUrl = "") { if (ModelState.IsValid) { var usbKeyNo = Request.Cookies["KOAL_CERT_CN"]?.Trim(); usbKeyNo = usbKeyNo ?? ""; var loginResult = await _accountAppService.LoginAsync(model.UserName, model.Password, usbKeyNo); switch (loginResult.Result) { case EnumLoginResult.登录成功: case EnumLoginResult.强制修改密码: var client = await _clientAppService.GetClient(model.DeviceCode); if (client != null) { returnUrl = string.IsNullOrWhiteSpace(returnUrl) ? client.HomePage : returnUrl; } await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, loginResult.ClaimsPrincipal, new AuthenticationProperties { IsPersistent = model.RememberMe, ExpiresUtc = DateTimeOffset.Now.AddMinutes(_accountSettings.Value.ExpiryTime) }); returnUrl = string.IsNullOrEmpty(returnUrl) ? "/Home/Index" : returnUrl; return(Redirect(returnUrl)); default: ViewBag.ErrorMessage = loginResult.ToString(); break; } } ViewBag.ErrorMessage = ViewBag.ErrorMessage ?? ModelState.Values .FirstOrDefault(a => a.ValidationState == ModelValidationState.Invalid) ?.Errors.FirstOrDefault() ?.ErrorMessage; return(View(model)); }
public async Task <IActionResult> CheckReceive(string deviceCode) { var result = new ResultEntity(); var client = await _clientAppService.GetClient(deviceCode); if (client == null) { result.Message = "未注册的客户端无法使用此功能"; } else { if (client.ClientType == EnumClientType.个人终端) { result.Message = "请在自助终端使用打印功能"; } else { var objects = await _exchangeObjectAppService.GetObjects(CurrentUser.UserId, client.PlaceId); if (objects.Count == 0) { result.Message = "暂无清单"; } else { result.Success = true; result.Data = objects.Select(a => new SelectViewModel { Id = a.Id, Text = a.Name }).Distinct(); } } } return(Json(result)); }