protected virtual async Task UpdateAsync(CreateOrEditEmployerDto input) { var entity = await employerRepository.GetAll() .FirstOrDefaultAsync(p => p.Id == input.Id); ObjectMapper.Map(input, entity); await employerRepository.UpdateAsync(entity); }
protected virtual async Task CreateUserAsync(CreateOrEditEmployerDto input) { var entity = ObjectMapper.Map <Employer>(input); await employerRepository.InsertAndGetIdAsync(entity); await CurrentUnitOfWork.SaveChangesAsync(); }
public async Task <CreateOrEditEmployerDto> GetForEdit(int?id) { var model = new CreateOrEditEmployerDto(); if (id == null) { return(model); } var entity = await employerRepository.GetAll() .FirstOrDefaultAsync(p => p.Id == id); entity.MapTo(model); //model = model.Translations // .Concat(translations) // .DistinctBy(p => p.Language) // .ToList(); return(model); }
//public bool CheckPassword(string password) //{ // //string MatchEmailPattern = "(?=.{6,})[a-zA-Z0-9]+[^a-zA-Z]+|[^a-zA-Z]+[a-zA-Z]+"; // string MatchEmailPattern = "^[a-zA-Z0-9]+$"; // if (password != null ) return Regex.IsMatch(password, MatchEmailPattern); // else return false; //} //[AbpAuthorize(PermissionNames.AdminPage_Employer)] public async Task CreateOrUpdate(CreateOrEditEmployerDto input) { var email = employerRepository.GetAll() .FirstOrDefault(p => p.EmailAddress == input.EmailAddress); if (input.Id != 0) { if (input.EmailAddress == null || input.UserName == null || input.Password == null) { throw new ArgumentNullException("Chưa nhập đủ thông tin"); } await UpdateAsync(input); } else { if (input.EmailAddress == null || email != null || input.UserName == null || input.Password == null) { throw new ArgumentNullException("Chưa nhập đủ thông tin"); } await CreateUserAsync(input); } }