public async Task <ApiRequestResult> DeleteAsync(Guid id) { await _iTRoleRepository.DeleteAsync(id); //_unitOfWork.SaveChanges(); return(ApiRequestResult.Success("删除成功")); }
public async Task <ApiRequestResult> AddAsync(ProductAttributeCategoryDto dto) { var command = dto.EntityMap <ProductAttributeCategoryDto, ProductAttributeCategory>(); await _productAttributeCategoryRepository.AddAsync(command); return(ApiRequestResult.Success("添加成功")); }
public async Task <ApiRequestResult> QueryProductCateWithAttrAsync() { try { var productAttrCates = await _productAttributeCategoryRepository.QueryAsync(c => true); var list = new List <ProductAttrCateWithAttrDto>(); foreach (var item in productAttrCates.ToList()) { var productAttrCateDto = new ProductAttrCateWithAttrDto { Id = item.Id, Name = item.Name, }; var productCategoryAttr = await _productAttributeRepository.QueryAsync(c => c.ProductAttributeCategoryId == item.Id); productAttrCateDto.ProductAttributes = productCategoryAttr.Select(c => c.EntityMap <ProductAttribute, ProductAttributeDto>()).ToList(); list.Add(productAttrCateDto); } return(ApiRequestResult.Success(list, "")); } catch (Exception ex) { throw; } }
public async Task <ApiRequestResult> AddAsync(GrowthChangeHistoryDto dto) { var command = dto.EntityMap <GrowthChangeHistoryDto, GrowthChangeHistory>(); await _growthChangeHistoryRepository.AddAsync(command); return(ApiRequestResult.Success("添加成功")); }
public async Task <ApiRequestResult> AddAsync([FromBody] UserParam param) { var userId = Guid.NewGuid(); var asampleUser = new ASampleUser { Id = userId.ToString(), UserName = param.UserName, Email = param.Email, PhoneNumber = param.PhoneNumber, }; var hashedNewPassword = _userManager.PasswordHasher.HashPassword(asampleUser, param.Password); var user = new TUser { Id = userId, UserName = param.UserName, Email = param.Email, PhoneNumber = param.PhoneNumber, Password = hashedNewPassword, OrgId = param.OrgId, LoginName = param.LoginName, }; var result = await _userManager.CreateAsync(asampleUser, param.Password); if (result.Succeeded) { await _iTUserRepository.AddAsync(user); return(ApiRequestResult.Success("添加成功")); } return(ApiRequestResult.Error(result.Errors.FirstOrDefault().Description)); }
public async Task <ApiRequestResult> SignIn([FromBody] SignInCommand command) { try { var ip = _accessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(); var result = await _identityServices.SignInAsync(command.UserName, command.Password, UserType.Member); var redisExpireTime = _configuration.GetSection("redis:expiryMinutes").Value.ToString(); var expirtime = new DistributedCacheEntryOptions { AbsoluteExpiration = DateTime.Now.AddMinutes(Convert.ToInt32(redisExpireTime)) }; await _cache.SetStringAsync(result.AccessToken, JsonConvert.SerializeObject(result), expirtime); var data = new { tokenHead = "Bearer", token = result.AccessToken }; //添加登录记录 await _userLoginRepository.AddAsync(new UserLogin { UserId = Guid.Parse(result.Id), LoginProvider = "ManageSystem", ProviderDisplayName = "管理系统", ProviderKey = Guid.NewGuid().ToString(), LoginIp = ip }); return(ApiRequestResult.Success(data, "登录成功")); } catch (Exception ex) { return(ApiRequestResult.Error("账号密码错误,请重新输入")); throw ex; } }
public async Task <ApiRequestResult> AddAsync(TopicCommentDto dto) { var command = dto.EntityMap <TopicCommentDto, TopicComment>(); await _topicCommentRepository.AddAsync(command); return(ApiRequestResult.Success("添加成功")); }
public async Task <ApiRequestResult> AddAsync(SubjectCategoryDto dto) { var command = dto.EntityMap <SubjectCategoryDto, SubjectCategory>(); await _subjectCategoryRepository.AddAsync(command); return(ApiRequestResult.Success("添加成功")); }
public async Task <ApiRequestResult> SignUpAsync(SignUpCommand command) { await _identityServices.SignUpAsync(command.Email, command.PhoneNumber, command.UserName, command.Password, UserType.Member); return(ApiRequestResult.Success("注册成功")); }
public async Task <ApiRequestResult> AddAsync(FlashPromotionDto dto) { var command = dto.EntityMap <FlashPromotionDto, FlashPromotion>(); await _flashPromotionRepository.AddAsync(command); return(ApiRequestResult.Success("添加成功")); }
public async Task <ApiRequestResult> GetAsync() { var token = HttpContext.Request.Headers["Authorization"].ToString(); var key = token.Replace("Bearer", "").Trim(); var jsonRedis = await _cache.GetStringAsync(key); if (jsonRedis.IsNullOrEmpty()) { return(ApiRequestResult.Error("登录已过期", HttpStatusCode.Unauthorized)); } var jsonWebToken = JsonConvert.DeserializeObject <JsonWebToken>(jsonRedis); var accountUser = await _identityServices.GetAsync(Guid.Parse(jsonWebToken.Id)); var roles = new List <string> { "TEST" }; var userInfo = new UserInfoDto { UserName = accountUser.UserName, Roles = roles, }; return(ApiRequestResult.Success(userInfo, "")); }
public async Task <ApiRequestResult> AddAsync(HomeAdvertiseDto dto) { var command = dto.EntityMap <HomeAdvertiseDto, HomeAdvertise>(); await _homeAdvertiseRepository.AddAsync(command); return(ApiRequestResult.Success("添加成功")); }
public async Task <ApiRequestResult> AddAsync(MemberReceiveAddressDto dto) { var command = dto.EntityMap <MemberReceiveAddressDto, MemberReceiveAddress>(); await _memberReceiveAddressRepository.AddAsync(command); return(ApiRequestResult.Success("添加成功")); }
public async Task <ApiRequestResult> AddAsync(ProductSkuStockDto dto) { var command = dto.EntityMap <ProductSkuStockDto, ProductSkuStock>(); await _productSkuStockRepository.AddAsync(command); return(ApiRequestResult.Success("添加成功")); }
public async Task <ApiRequestResult> AddAsync(OrderSettingDto dto) { var command = dto.EntityMap <OrderSettingDto, OrderSetting>(); await _orderSettingRepository.AddAsync(command); return(ApiRequestResult.Success("添加成功")); }
public async Task <ApiRequestResult> AddAsync(MenuDto dto) { var menu = dto.EntityMap <MenuDto, Menu>(); await _menuRepository.AddAsync(menu); return(ApiRequestResult.Success("添加成功")); }
/// <summary> /// Coroutine which handles the request sending. /// </summary> /// <returns></returns> public IEnumerator send() { SEND_API_REQUEST: if (!t_require_online || m_api_manager.pt_online) { ApiRequestResult result = new ApiRequestResult(); yield return(RequestManager.getInstance().pt_api_request.send(t_url, this, ref result)); m_tries++; if (result.pt_www_error || result.pt_auth_error || result.pt_auth_user_error) { // request was not successful if (m_tries > m_api_manager.p_timeout_tries) { // if out of number of tries logout m_api_manager.setTimeout(); } else { // if number of tries less than or equal to timeout tries, try again goto SEND_API_REQUEST; } } else { // if everything ok process response handleResult(result); } } pt_done = true; }
protected override void handleResult(ApiRequestResult result) { if (result.pt_verified) { this.pt_response = JsonUtility.FromJson <OrderNewResponse>(result.pt_response_decoded); } }
public ApiRequestResult SignIn(AuthUser user) { var userInfo = CustomerServices.GetUserInfoByName(user.UserName); if (userInfo == null) { return(ApiRequestResult.Error("用户不存在,请先注册")); } var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(userInfo.AuthType)); var credentials = new SigningCredentials(key, SecurityAlgorithms.HmacSha256Signature); var expirationDate = DateTime.UtcNow.AddHours(2); var claims = new[] { new Claim(ClaimTypes.Name, userInfo.UserName.ToString()), new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()) }; var token = new JwtSecurityToken(audience: userInfo.Audience, issuer: userInfo.Issuer, claims: claims, expires: expirationDate, signingCredentials: credentials); var authToken = new AuthToken { Token = new JwtSecurityTokenHandler().WriteToken(token), ExpirationDate = expirationDate }; return(ApiRequestResult.Success(authToken, "登录成功")); }
public ApiRequestResult GetTimeOut() { var thread = Thread.CurrentThread; thread.Name = "MainThread"; Thread.Sleep(10000);// 挂起半秒 return(ApiRequestResult.Error("线程超时")); }
public async Task <ApiRequestResult> UpdateStatusAsync(Guid id, bool status) { var entity = await _topicCategoryRepository.GetAsync(id); await _topicCategoryRepository.UpdateAsync(entity); return(ApiRequestResult.Success("修改成功")); }
public async Task <ApiRequestResult> UpdateStatusAsync(Guid id, bool showStatus) { var entity = await _productAttributeRepository.GetAsync(id); await _productAttributeRepository.UpdateAsync(entity); return(ApiRequestResult.Success("修改成功")); }
public async Task <ApiRequestResult> UpdateAsync(ProductAttributeDto dto) { var entity = await _productAttributeRepository.GetAsync(dto.Id.Value); var newEntity = dto.EntityMap(entity); await _productAttributeRepository.UpdateAsync(newEntity); return(ApiRequestResult.Success("修改成功")); }
public async Task <ApiRequestResult> UpdateFactoryAsync(Guid id, bool factoryStatus) { var entity = await _brandRepository.GetAsync(id); entity.FactoryStatus = factoryStatus; await _brandRepository.UpdateAsync(entity); return(ApiRequestResult.Success("修改成功")); }
public async Task <ApiRequestResult> UpdateStatusAsync(Guid id, bool status) { var entity = await _prefrenceAreaRepository.GetAsync(id); entity.ShowStatus = status; await _prefrenceAreaRepository.UpdateAsync(entity); return(ApiRequestResult.Success("修改成功")); }
public async Task <ApiRequestResult> UpdateAsync(UserDto dto) { var entity = await _userRepository.GetAsync(dto.Id); var newEntity = dto.EntityMap(entity); await _userRepository.UpdateAsync(newEntity); return(ApiRequestResult.Success("修改成功")); }
public async Task <ApiRequestResult> UpdateNavStatusAsync(Guid id, bool showStatus) { var entity = await _productCategoryRepository.GetAsync(id); entity.NavStatus = showStatus; await _productCategoryRepository.UpdateAsync(entity); return(ApiRequestResult.Success("修改成功")); }
public async Task <ApiRequestResult> UpdateStatusAsync(Guid id, bool status) { var entity = await _integrationConsumeSettingRepository.GetAsync(id); //entity.ShowStatus = showStatus; await _integrationConsumeSettingRepository.UpdateAsync(entity); return(ApiRequestResult.Success("修改成功")); }
public async Task <ApiRequestResult> UpdateAsync(IntegrationConsumeSettingDto dto) { var entity = await _integrationConsumeSettingRepository.GetAsync(dto.Id.Value); var newEntity = dto.EntityMap(entity); await _integrationConsumeSettingRepository.UpdateAsync(newEntity); return(ApiRequestResult.Success("修改成功")); }
public async Task <ApiRequestResult> UpdateAsync(MemberLevelDto dto) { var entity = await _memberLevelRepository.GetAsync(dto.Id.Value); var newEntity = dto.EntityMap(entity); await _memberLevelRepository.UpdateAsync(newEntity); return(ApiRequestResult.Success("修改成功")); }
public ApiRequestResult ChangeClaimTenderStatus(int idClaim, int status, string sig) { var model = new ApiRequestResult() {IsComplete = false, Message = string.Empty, ErrorCode = 0}; try { //проверка sig var md5 = MD5.Create(); var key = ConfigurationManager.AppSettings["AppKey"]; var paramArr = new[] { "idClaim=" + idClaim, "status=" + status }; var validSig = GetMd5Hash(md5, string.Join(string.Empty, paramArr) + key); var isSigValid = sig == validSig; if (isSigValid) { //изменение статуса var db = new DbEngine(); var tenderStatus = db.LoadTenderStatus(); if (tenderStatus.FirstOrDefault(x => x.Id == status) == null) { model.Message = "Status is not valid"; model.ErrorCode = 3; } else { var claim = db.LoadTenderClaimById(idClaim); if (claim == null) { model.Message = "Claim with Id = " + idClaim + " is not exists"; model.ErrorCode = 4; } else { model.IsComplete = DbEngine.ChangeTenderClaimTenderStatus(idClaim, status); } } } else { model.Message = "Sig is not valid"; model.ErrorCode = 2; } } catch (Exception) { model.IsComplete = false; model.Message = "Server error"; model.ErrorCode = 1; } return model; }