public Result Create(SeoPageCreateAdminDto dto) { var result = _validatorCreate.ValidateResult(dto); if (!result.Success) { return(result); } var entity = Mapper.Map <SeoPage>(dto); _seoPageRepository.Insert(entity); _unitOfWork.Commit(); SeoPageCacheManager.ClearCache(); result.Id = entity.Id; return(result.SetSuccess(Messages.RecordSaved)); }
public Result Edit(int id, SeoPageEditAdminDto dto) { dto.Id = id; var result = _validatorEdit.ValidateResult(dto); if (!result.Success) { return(result); } if (dto.Id > 0) { var entity = _seoPageRepository.AsNoTracking.FirstOrDefault(w => w.Id == dto.Id); if (entity == null) { return(result.SetError("There are error for update record. Please try again with refresh.")); } Mapper.Map <SeoPage>(dto, entity); _seoPageRepository.Update(entity); _unitOfWork.Commit(); result.Id = entity.Id; } else { var entity = Mapper.Map <SeoPage>(dto); _seoPageRepository.Insert(entity); _unitOfWork.Commit(); result.Id = entity.Id; } SeoPageCacheManager.ClearCache(); return(result.SetSuccess(Messages.RecordSaved)); }