public async Task <User> GetUserByUserPassAsync(string userName, string password, CancellationToken cancellationToken) { if (!userName.HasValue() || !password.HasValue()) { throw new BadRequestException("نام كاربري يا كلمه عبور وارد نشده"); } var passwordHash = SecurityHelper.GetSha256Hash(password); return(await TableNoTracking.SingleOrDefaultAsync(p => p.UserName == userName && p.PasswordHash == passwordHash, cancellationToken)); }
public async Task <bool> AddTag(PostTagDto dto, CancellationToken cancellationToken) { Assert.NotEmpty(dto.TagName, "list", "لیست تگ ها خالی است"); Assert.NotNull(dto.PostId, "آی دی پست نامعتبر است"); foreach (var tagDto in dto.TagName) { var isTagExist = await TableNoTracking.SingleOrDefaultAsync(a => a.Name.Equals(tagDto), cancellationToken); if (isTagExist == null) { var newTag = new Tag { Name = tagDto, VersionStatus = 0, Version = 1 }; await AddAsync(newTag, cancellationToken); var postTag = new PostTag { PostId = dto.PostId, TagId = newTag.Id, VersionStatus = 0, Version = 1 }; await _repositoryPostTag.AddAsync(postTag, cancellationToken, false); } else { var postTag = new PostTag { PostId = dto.PostId, TagId = isTagExist.Id, VersionStatus = 0, Version = 1 }; await _repositoryPostTag.AddAsync(postTag, cancellationToken, false); } } var save = await DbContext.SaveChangesAsync(cancellationToken); return(Convert.ToBoolean(save)); }
public async Task <SweetAlertExtenstion> UpdateInfo(SiteInfoUpdateViewModel vm) { var entity = await TableNoTracking.SingleOrDefaultAsync(); if (vm.LogoFile != null) { entity.Logo = await MFile.Save(vm.LogoFile, "Uploads/SiteSetting"); } if (vm.BackGroudLoginPageFile != null) { entity.BackGroudLoginPage = await MFile.Save(vm.BackGroudLoginPageFile, "Uploads/SiteSetting"); } entity.SiteName = vm.SiteName; Entities.Update(entity); await DbContext.SaveChangesAsync(); return(SweetAlertExtenstion.Ok()); }
public async Task <SiteSetting> GetInfo() { return(await TableNoTracking.SingleOrDefaultAsync()); }